Skip to content

Lazy broadcast channel #373

@shsms

Description

@shsms

What's needed

Still need to come up with a new name for this broadcast channel configuration, but I think it would be nice to get broadcast channels that pause on overflowing receivers. (without blocking sender.send)

Receiver behaviour

When a receiver is not being consumed from for a certain duration, the channel stops sending to it. If the receiver is awaited again, it gets treated like a new receiver, starting with an empty buffer, and respecting resend_latest.

Sender behaviour

The send methods don't block, so it is the same behaviour as now, but the sender has a property and an async method which can be used to prevent wasteful work, like this:

if not sender.has_active_receivers:
    await sender.wait_for_receivers()

This would prevent the sending side from doing active work, and possibly stop receiving from its upstream and stop work on that level as well.

So channels would finally transmit information about receivers to the sending side, if they are interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:channelsAffects channels implementationpart:coreAffects the core types (`Sender`, `Receiver`, exceptions, etc.)

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions