Skip to content

Commit eafc942

Browse files
authored
Make sure that the ETOS publisher is properly closed (#34)
1 parent 6cabcf0 commit eafc942

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/etos_api/routers/etos/router.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,15 @@ async def start_etos(etos: StartEtosRequest):
110110

111111
LOGGER.info("Start event publisher.")
112112
await sync_to_async(etos_library.start_publisher)
113+
await sync_to_async(etos_library.publisher.wait_start)
113114
LOGGER.info("Event published started successfully.")
114115
LOGGER.info("Publish TERCC event.")
115-
async with aclosing(etos_library.publisher):
116+
try:
116117
event = etos_library.events.send(tercc, links, data)
118+
await sync_to_async(etos_library.publisher.wait_for_unpublished_events)
119+
finally:
120+
await sync_to_async(etos_library.publisher.stop)
121+
await sync_to_async(etos_library.publisher.wait_close)
117122
LOGGER.info("Event published.")
118123

119124
LOGGER.info("ETOS triggered successfully.")

0 commit comments

Comments
 (0)