Good afternoon.
I'm trying to use the NOTIFY/LISTEN feature in PostgreSQL, as seen in the asyncpg docs we can add a listener to a Connection object, but not a Pool, I've tried the solutions shown in this issue, code below:
def listener(*args):
print("ANYTHING")
async def main():
creds = {}
async def add_listeners(conn) -> None:
await conn.add_listener("listener_channel", listener)
pool = await asyncpg.create_pool(**creds, setup=add_listeners)
await asyncio.sleep(10000)
asyncio.run(main())
And then running
NOTIFY listener_channel
In PgAdmin4.
However - nothing happens. How could I make it work?