(fix) stability imp: completion() timeout during high traffic, should not raise exception

This commit is contained in:
ishaan-jaff 2023-11-06 17:54:35 -08:00
parent e0116d2991
commit ce4423e213

View file

@ -89,8 +89,15 @@ class _LoopWrapper(Thread):
self.loop = asyncio.new_event_loop() self.loop = asyncio.new_event_loop()
def run(self) -> None: def run(self) -> None:
try:
self.loop.run_forever() self.loop.run_forever()
self.loop.call_soon_threadsafe(self.loop.close) self.loop.call_soon_threadsafe(self.loop.close)
except Exception as e:
# Log exception here
pass
finally:
self.loop.close()
asyncio.set_event_loop(None)
def stop_loop(self): def stop_loop(self):
for task in asyncio.all_tasks(self.loop): for task in asyncio.all_tasks(self.loop):