Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andersea opened this issue Nov 18, 2021 · 0 comments

Comments

@andersea
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant