From: | "John D(dot) Burger" <john(at)mitre(dot)org> |
---|---|
To: | "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: LISTEN/NOTIFY and python |
Date: | 2007-03-20 17:44:43 |
Message-ID: | 39DE6D28-6DDA-460C-B2B7-D76C04B59EEB@mitre.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> The standard approach when using libpq directly is to get the file
> descriptor number of the backend connection with PQsocket(), then
> include that in the set of FDs that the client app's idle loop
> select()s or poll()s on.
And Tino Wildenhain, in off-list mail, described getting the socket-
fd from the PyGreSQL connection object and doing something analogous.
It turns out that Python's listen() takes ints =or= objects with a
fileno() method, whence it gets the int, and PyGreSQL's connection
objects qualify. So I can do this:
import pg, select
con = pg.connect(...)
con.query("listen foo")
while True:
select.select([con], [], []) # Wait for it ...
print con.getnotify()
I wish I could do this with the more "standard" pgdb module, but,
then again, LISTEN/NOTIFY aren't standard. Thanks, Tino and Tom, for
the pointers toward this solution.
- John D. Burger
MITRE
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2007-03-20 17:53:14 | Re: Reference Type in PostgreSQL |
Previous Message | Benjamin Arai | 2007-03-20 17:41:55 | SoC Ideas for people looking for projects |