usim icon indicating copy to clipboard operation
usim copied to clipboard

GC of coroutines/events leaks state between loops

Open maxfischer2781 opened this issue 3 years ago • 0 comments

Description of the bug When a loop ends and leaves behind objects, collecting them after a new loop starts transfers state between the two loops. This is because usim objects interact with the "current" event loop; delayed cleanup means the current loop is the wrong one.

How To Reproduce No repro yet. Encountered this in lapis when cleaning an async generator is cleaned up.

Expected behavior Objects should not leak. We might have to register objects and explicitly clean them up. Keep in mind that not registering was an explicit design decision to avoid overhead; if needed, restrict it to objects that need it.

  • Consider sys.set_asyncgen_hooks to link async generators (the most likely culprit) to the event loop.
  • Consider gc.collect whenever a loop finishes and/or starts.

maxfischer2781 avatar Dec 11 '20 10:12 maxfischer2781