1
+ from __future__ import annotations
2
+
1
3
import argparse
2
4
import asyncio
3
5
import inspect
@@ -32,7 +34,9 @@ def register(self, parser: argparse.ArgumentParser):
32
34
33
35
# Load all protocols from __init__.py
34
36
with open (os .path .join (opengsq_path , "protocols" , "__init__.py" )) as f :
35
- for protocol_path , protocol_classnames in re .findall (pattern , f .read ()):
37
+ matches : list [str , str ] = re .findall (pattern , f .read ())
38
+
39
+ for protocol_path , protocol_classnames in matches :
36
40
for protocol_classname in protocol_classnames .split ("," ):
37
41
name , fullpath , parameters = self .__extract (
38
42
protocol_path , protocol_classname
@@ -130,9 +134,7 @@ def __add_arguments(
130
134
131
135
132
136
def main ():
133
- loop = asyncio .get_event_loop ()
134
- loop .run_until_complete (main_async ())
135
- loop .close ()
137
+ asyncio .run (main_async ())
136
138
137
139
138
140
async def main_async ():
@@ -152,6 +154,9 @@ async def main_async():
152
154
except asyncio .exceptions .TimeoutError :
153
155
sys .stderr .write ("opengsq: error: timed out\n " )
154
156
sys .exit (- 2 )
157
+ except asyncio .exceptions .CancelledError :
158
+ sys .stderr .write ("opengsq: error: cancelled\n " )
159
+ sys .exit (- 3 )
155
160
156
161
sys .exit (0 )
157
162
0 commit comments