try another way to stop a leak

This commit is contained in:
Inex Code 2024-11-11 20:31:18 +03:00
parent cd83f18ee8
commit 77132d8ce3

View file

@ -21,6 +21,7 @@ async def log_stream() -> AsyncGenerator[LogEntry, None]:
asyncio.get_event_loop().add_reader(j, lambda: asyncio.ensure_future(callback())) asyncio.get_event_loop().add_reader(j, lambda: asyncio.ensure_future(callback()))
try:
while True: while True:
entry = await queue.get() entry = await queue.get()
try: try:
@ -30,3 +31,7 @@ async def log_stream() -> AsyncGenerator[LogEntry, None]:
j.close() j.close()
return return
queue.task_done() queue.task_done()
except asyncio.CancelledError:
asyncio.get_event_loop().remove_reader(j)
j.close()
return