Skip to content

Commit 1761144

Browse files
committed
fix(CLI): Support the new async functions from the CLI
1 parent d3d707e commit 1761144

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ and commits should be formatted using [Conventional Commits](https://www.convent
88

99
## [Unreleased]
1010

11+
### Added
12+
13+
- Async: Provide a new `atop_n_routes()` function for async contexts by @stronk7 ([d3d707e](https://github.com/moodlehq/asero/commit/d3d707e448801e8f749f999d815683bce74d63ed))
14+
1115
### Changed
1216

13-
- Dependencies: Bump various libraries.
17+
- Dependencies: Bump various libraries by @stronk7 ([4342f2a](https://github.com/moodlehq/asero/commit/4342f2af949d0770692ad95f1f841b212ac2e6fb))
1418

1519
### Fixed
1620

1721
- Docs: Solve a configuration problem with CHANGELOG generation by @stronk7 ([f7d4032](https://github.com/moodlehq/asero/commit/f7d403253f96e8eafe091441832c5d26a6402d58))
22+
- CLI: Support the new async functions from the CLI.
1823
## [0.3.0] - 2025-09-15
1924

2025
### Added

asero/main.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
"""Main module, demonstration purposes, for asero semantic router."""
55
import asyncio
6+
import sys
7+
import traceback
68

79
from asero.config import get_config
810
from asero.router import SemanticRouter
911

1012

11-
async def main():
13+
async def run():
1214
"""Demonstrate the SemanticRouter functionality."""
1315
config = get_config()
1416
router = SemanticRouter(config) # Defaults to router_example.yaml
@@ -33,5 +35,21 @@ async def main():
3335
break
3436

3537

38+
def main():
39+
"""Prepare the async loop for operation and graceful shutdown, then run()."""
40+
# Create the event loop, set it as current and add the signal handlers.
41+
loop = asyncio.get_event_loop_policy().new_event_loop()
42+
asyncio.get_event_loop_policy().set_event_loop(loop)
43+
exitcode = 0
44+
try:
45+
loop.run_until_complete(run()) # Run the main loop.
46+
except Exception:
47+
traceback.print_exc()
48+
exitcode = 1
49+
finally:
50+
loop.close()
51+
sys.exit(exitcode)
52+
53+
3654
if __name__ == "__main__":
37-
asyncio.run(main())
55+
main()

0 commit comments

Comments
 (0)