Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Errore in Select.select

#8

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

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

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • 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)==([],[],[]):
    

    November 8th, 2010 @ 05:32 PM