From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Danny Milosavljevic <danny(dot)milo(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: psycopg2 (async) socket timeout |
Date: | 2011-02-03 20:35:50 |
Message-ID: | AANLkTin3inFX=0wXSwEo9xEUnc8sRM_xBX=7T1iW81yR@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Thu, Feb 3, 2011 at 8:04 PM, Danny Milosavljevic
<danny(dot)milo(at)gmail(dot)com> wrote:
> Hello,
>
> is it possible to specify the timeout for the socket underlying a connection?
You can send a command SET statement_timeout to affect all the
commands further sent to the connection
http://www.postgresql.org/docs/9.0/static/runtime-config-client.html#GUC-STATEMENT-TIMEOUT
> Alternatively, since I'm using the async interface anyway, is it
> possible proactively cancel a query that is "stuck" since the TCP
> connection to the database is down?
Jan has contributed a connection.cancel() method, available since psycopg 2.3
http://initd.org/psycopg/docs/connection.html#connection.cancel
> 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?
Probably canceling the query from the client: if the network is down
you wouldn't get the signal that the backend timed out. But I've never
dealt with this scenario myself so I guess you should test if any of
the above works for you :)
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Federico Di Gregorio | 2011-02-06 16:26:51 | RELEASE: 2.4 beta 1 |
Previous Message | Danny Milosavljevic | 2011-02-03 20:04:39 | psycopg2 (async) socket timeout |