Skip to content

GC of coroutines/events leaks state between loops #101

@maxfischer2781

Description

@maxfischer2781

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions