Re: psycopg2 (async) socket timeout

From: Mark Theisen <mark(dot)theisen(at)digitecinc(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-09 19:18:16
Message-ID: 26856422.494.1297279096146.JavaMail.root@zimbra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

You could add connect_timeout to the dsn, e.g. dsn = "host='localhost' dbname='test' connect_timeout=60". http://www.postgresql.org/docs/8.4/static/libpq-connect.html#AEN33199. I don't know if this will help with your situation, but it might.

Mark

----- Original Message -----
From: "Danny Milosavljevic" <danny(dot)milo(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Sent: Thursday, February 3, 2011 2:04:39 PM
Subject: [psycopg] psycopg2 (async) socket timeout

Hello,

is it possible to specify the timeout for the socket underlying a connection?

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?

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?

Regards,
Danny

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-02-11 16:16:59 Psycopg on OSX
Previous Message Jan Urbański 2011-02-09 19:00:46 Re: psycopg2 (async) socket timeout