logo       

Re: notify.py: msg#00081

python.db.psycopg.devel

Subject: Re: notify.py

Federico Di Gregorio wrote:
Il giorno ven, 17/03/2006 alle 13.07 -0600, Michael Hipp ha scritto:
I'm trying to refactor some of my code to use the "new" method of doing a LISTEN on the database, I'm stuck on this key piece of code:

print "Waiting for 'NOTIFY test'"
while 1:
if select.select([curs],[],[],5)==([],[],[]):
print "Timeout"
else:
if curs.isready():
print "Got NOTIFY: %s" % str(curs.connection.notifies.pop())


I understand the 'select' part.

What does curs.isready() do? What happens if it comes back as not True?

It just means that the current data transfer from the backend is still
in progress. But given the fact that only the Really Brave (TM) would
use psycopg async calls right now it will never happen to you (but you
must still call .isready() because it will gather the pending notifies.)

Thank you.

In production code, would it be generally advisable to put a try/except block around the curs.isready() and curs.connection.notifies() ?

Thanks,
Michael


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise