Skip to content

Commit

Permalink
Make sure that the ETOS publisher is properly closed (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-persson committed Jan 20, 2022
1 parent 6cabcf0 commit eafc942
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/etos_api/routers/etos/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,15 @@ async def start_etos(etos: StartEtosRequest):

LOGGER.info("Start event publisher.")
await sync_to_async(etos_library.start_publisher)
await sync_to_async(etos_library.publisher.wait_start)
LOGGER.info("Event published started successfully.")
LOGGER.info("Publish TERCC event.")
async with aclosing(etos_library.publisher):
try:
event = etos_library.events.send(tercc, links, data)
await sync_to_async(etos_library.publisher.wait_for_unpublished_events)
finally:
await sync_to_async(etos_library.publisher.stop)
await sync_to_async(etos_library.publisher.wait_close)
LOGGER.info("Event published.")

LOGGER.info("ETOS triggered successfully.")
Expand Down

0 comments on commit eafc942

Please sign in to comment.