Re: psycopg2 (async) socket timeout
От | Daniele Varrazzo |
---|---|
Тема | Re: psycopg2 (async) socket timeout |
Дата | |
Msg-id | AANLkTin3inFX=0wXSwEo9xEUnc8sRM_xBX=7T1iW81yR@mail.gmail.com обсуждение исходный текст |
Ответ на | psycopg2 (async) socket timeout (Danny Milosavljevic <danny.milo@gmail.com>) |
Список | psycopg |
On Thu, Feb 3, 2011 at 8:04 PM, Danny Milosavljevic <danny.milo@gmail.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
В списке psycopg по дате отправления: