Skip to content

New listen helper with backpressure using new asyncpg add_listener api from v0.24 #17

Open
@andersea

Description

@andersea

I originally came up with the listen helper for my personal code and I am very happy to see it implemented directly in triopg.

Now in asyncpg v0.24 add_listener now allows the callback to a coroutine. This allows the posibility of another message passing strategy where backpressure is allowed.

The callback function could concievably be as simple as:

async def _listen_callback(c, pid, chan, payload):
        await trio_asyncio.trio_as_aio(send_channel.send)(payload)

The wrapper is necessary, since the callback is running in asyncio, and MemorySendChannel.send does stuff with trio.lowlevel.current_task().

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions