Re: psycopg2 (async) socket timeout - Mailing list psycopg

From Jan Urbański
Subject Re: psycopg2 (async) socket timeout
Date
Msg-id 1297278046.2509.8.camel@Nokia-N900-42-11
Whole thread Raw
In response to psycopg2 (async) socket timeout  (Danny Milosavljevic <danny.milo@gmail.com>)
Responses Re: psycopg2 (async) socket timeout  (Danny Milosavljevic <danny.milo+ml@gmail.com>)
List psycopg
----- Original message -----
> So the specific case is:
> - connect to the postgres database using psycopg2 while network is up
> - run some queries, get the results fine etc
> - send a query
> - the network goes down before the result to this last query has been
> received - neither a result nor an error callback gets called - as far
> as I can see (using txpostgres.ConnectionPool)
>
> What's the proper way to deal with that?

I'll try to reproduce this problem, AIUI you should have the Deferred errback if the connection is lost, but perhaps it
takessome time for Twisted to detect it (actually it takes time for the kernel to detect it). You might try playing
withyour TCP keepalive settings. 

Another option is implementing a timeout with a callLater. The problem there is that it requires additional code and
txpostgresdoes not support query cancellation (yet, it's on the roadmap). 

Cheers,
Jan

psycopg by date:

Previous
From: Nicolas Grilly
Date:
Subject: Re: copy_from does not stop reading after an error
Next
From: Mark Theisen
Date:
Subject: Re: psycopg2 (async) socket timeout