Marcelo Fernandez | 28 Aug 2010 18:31
Picon
Gravatar

Notify examples

Hello there,

I was trying to make a basic example of notify/listen and I've found a
big difference in the select() call between the examples directory [1]
and the official docs version [2].

The first one say:

select.select([curs],[],[],5)==([],[],[]):

but the docs say:

select.select([conn],[],[],5) == ([],[],[]):

Notice the difference in waiting input from cursor and from the
connection objects; which one is correct?

I'm using psycopg2 *v2.0* in Ubuntu 10.04, and if I try the docs
version (select([conn]...) it doesn't work:

marcelo <at> marcelo-laptop:~/desarrollo/pg_notify_example$ python notify_docs.py

Waiting for 'NOTIFY test'
Traceback (most recent call last):
  File "notify_docs.py", line 13, in <module>
    if select.select([conn],[],[],5) == ([],[],[]):
TypeError: argument must be an int, or have a fileno() method.

At first I tought there was a change in the psycopg2 *v2.2* version
(which will be available in Ubuntu 10.10), but the trunk/examples
version [1] (select([curs]...) does work perfectly.

Is it a mistake in the documentation? Or there was a change in *v2.2*?

[1] http://initd.org/svn/psycopg/psycopg2/trunk/examples/notify.py
[2] http://initd.org/psycopg/docs/advanced.html#asynchronous-notifications

Regards
--

-- 
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

E-Mail: marcelo.fidel.fernandez@...
Blog: http://blog.marcelofernandez.info
Twitter: http://twitter.com/fidelfernandez

Gmane