Skip to content

Commit 9197b0c

Browse files
Improved command-line utility
1 parent 89ea90c commit 9197b0c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

opengsq/cli.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import argparse
24
import asyncio
35
import inspect
@@ -32,7 +34,9 @@ def register(self, parser: argparse.ArgumentParser):
3234

3335
# Load all protocols from __init__.py
3436
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:
3640
for protocol_classname in protocol_classnames.split(","):
3741
name, fullpath, parameters = self.__extract(
3842
protocol_path, protocol_classname
@@ -130,9 +134,7 @@ def __add_arguments(
130134

131135

132136
def main():
133-
loop = asyncio.get_event_loop()
134-
loop.run_until_complete(main_async())
135-
loop.close()
137+
asyncio.run(main_async())
136138

137139

138140
async def main_async():
@@ -152,6 +154,9 @@ async def main_async():
152154
except asyncio.exceptions.TimeoutError:
153155
sys.stderr.write("opengsq: error: timed out\n")
154156
sys.exit(-2)
157+
except asyncio.exceptions.CancelledError:
158+
sys.stderr.write("opengsq: error: cancelled\n")
159+
sys.exit(-3)
155160

156161
sys.exit(0)
157162

opengsq/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.1.0'
1+
__version__ = '3.1.1'

0 commit comments

Comments
 (0)