python async with psycopg2

Поиск
Список
Период
Сортировка
От Rita
Тема python async with psycopg2
Дата
Msg-id CAOF-Kfh1P9eanS0hecw_E9Awdsmn3b4uYpnV5SdL8Xz31U2rBw@mail.gmail.com
обсуждение исходный текст
Ответы Re: python async with psycopg2
Список pgsql-general
I am trying to listen to multiple channels thru pg_notify mechanism.

select pg_notify('mychan0',foo');
select pg_notify('mychan'1,'bar');

In python I have something like this

import select,time
import psycopg2
import psycopg2.extensions
from psycopg2.extras import wait_select

DSN="dbname=mydb user=user host=localhost"

def main():

    conn = psycopg2.connect(DSN,async_=True)
    wait_select(conn)
    curs = conn.cursor()
    curs.execute("LISTEN mychan0;")
    #curs.execute("LISTEN mychan1;") #fails!
    wait_select(conn)
    while True:
        wait_select(conn)
        while conn.notifies:
            print("Notify: %s"%conn.notifies.pop().payload)
            time.sleep(1)
    conn.close()

I keep getting 

psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway

I prefer to stick with psycopg2 library instead of a wrapper. 
What am I doing wrong?

--
--- Get your facts first, then you can distort them as you please.--

В списке pgsql-general по дате отправления:

Предыдущее
От: Ailleen Pace
Дата:
Сообщение: DB Authentication with Label Security
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: python async with psycopg2