Open racinette opened 1 year ago
Is this still a problem? I just tried this small test and it seems to work fine (prints "Got notification" every second). I don't need to do any dummy queries.
import asyncpg
import asyncio
async def notify(conn):
count = 0
while True:
await asyncio.sleep(1)
await conn.execute(f"notify foo, '{count}'")
count += 1
async def notified(conn, pid, channel, payload):
print(f"Got notification on {channel}: {payload}")
async def main():
conn = await asyncpg.connect("postgresql://postgres:postgres@localhost")
await conn.add_listener("foo", notified)
await notify(conn)
asyncio.run(main())
Currently, you have to execute a dummy query like
SELECT 1
every time you want to get a hold of new notifications from the server. Can anything similar to aiopg be implemented in asyncpg?https://aiopg.readthedocs.io/en/stable/examples.html#usage-of-listen-notify-commands https://www.psycopg.org/docs/connection.html#connection.poll