This project is archived and is in readonly mode.

#8 ✓invalid
Psycopg website

Errore in Select.select

Reported by Psycopg website | November 8th, 2010 @ 05:14 PM

Submitted by: Marco Cassiano

N.B Errore già presente anche sulla 2.2.2

select.select (indipendentemente dalla versione di Postgres, 8.4 o 9.0.1) fallisce sulla referenziazione del cursore, peraltro aperto con successo.
Con la versione 2.2.1 funziona correttamente.

Codice e segnalazione :

import mdnlib
import psycopg2,psycopg2.extensions
import select # per la gestione del notify

def test_notify():

print 'Notify'
c = psycopg2.connect(host = d['host'], database=d['dbname'], user=d['user'], password=psw,port=d['port'])
c.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursore = c.cursor()


cur0 = c.cursor()
cur0.execute('LISTEN "scheduler"')
cur0.execute('LISTEN "schedulerKill"')
print('In attesa di notify "scheduler" e "schedulerKill";')
TIMEOUT = 8
i=1
while(i):
    i +=1

l’errore avviene sulla prossima riga

    if select.select([cur0],[],[], TIMEOUT)==([],[],[]):
        #self.logger.debug("Timeout(''keepalive'')!")
        pass
    else:
        if cur0.isready():
            lnotify = cur0.connection.notifies.pop()
            print ("Got NOTIFY: %s " % str(lnotify))
            if lnotify[1] == "schedulerKill": print 'self.kill()'
            elif lnotify[1] == "scheduler":   print 'self.run()'
            else: print ("Orrore: notify inaspettato !!!!")
    if i == 2: i=0

if name == 'main':

d = mdnlib.dns_postgres_nativo.copy()

test_notify()

______________________________________________ errore:___________________ Notify
In attesa di notify "scheduler" e "schedulerKill";
Traceback (most recent call last):
File "\intranetsvil\discoe tmp\bugPsycopg.py", line 39, in

test_notify()

File "\intranetsvil\discoe tmp\bugPsycopg.py", line 22, in test_notify

if select.select([cur0],[],[], TIMEOUT)==([],[],[]):

TypeError: argument must be an int, or have a fileno() method.

Process completed, Exit Code 1.
Execution time: 00:03.151

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo November 8th, 2010 @ 05:32 PM

    • State changed from “new” to “invalid”

    Hi Marco,

    there was a change in the async interface in psycopg2 2.2: the object you should put in the select is the connection, not the cursor.

    We know this broke backward compatibility, but async stuff was experimental (and broken) in 2.0. I don't think your code was working with 2.2.1, as cur.fileno() was dropped in 2.2.0: you may have had some previous version installed.

    Easy fix is:

    if select.select([cur0.connection],[],[], TIMEOUT)==([],[],[]):
    

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages