Skip to content

Improve async robustness and cleanup #411

@llucax

Description

@llucax

What happened?

When we wrote this library, we didn't fully understand the details of asyncio and how to do cleanup and cancellation properly. It is not a surprise, as this can be extremely tricky and the documention for asyncio is not great at specifying this. Because of this we ended up with some code that either is not cleaning up properly, or it is hard to clean up properly.

What did you expect instead?

Things to be more robust and clean up properly.

Affected version(s)

No response

Affected part(s)

Channels, Broadcast, Anycast, etc. (part:channels), Core types (Sender, Receiver, exceptions, etc.) (part:core), Experimental features (the experimental package) (part:experimental), Utilities (Event, FileWatcher, Timer, etc.) (part:utilities), Synchronization of multiple sources (select(), merge(), etc.) (part:synchronization)

Extra information

We should fix at least these:

  • Remove all __del__ methods
  • Make all classes that need cleanup a (async) context manager
  • Make select() an async context manager (make the function use the context manager and deprecate it)
  • Research if every call to await is a checkpoint. If not, we should probably add checkpoints to all async functions

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:channelsAffects channels implementationpart:coreAffects the core types (`Sender`, `Receiver`, exceptions, etc.)part:experimentalAffects the experimental packagepart:synchronizationAffects the synchronization of multiple sources (`select`, `merge`)part:utilitiesAffects the utility receivers (`Timer`, `Event`, `FileWatcher`)priority:highAddress this as soon as possibletype:bugSomething isn't working

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions