[Twisted-Python] Making ConnectionPool not pool
itamar at futurefoundries.com
Tue Nov 27 06:38:53 EST 2012
On Tue, Nov 27, 2012 at 4:16 AM, Hynek Schlawack <hs at ox.cx> wrote:
> I have a really bad time with the combination of a low-volume service and
> adbapi.ConnectionPool, pyodbc, FreeTDS and Sybase.
> Basically my connections just time out and fail in weird, generic ways
> Error: ('01000', ' [FreeTDS][SQL Server]Unexpected EOF from the
> server (20017) (SQLEndTran)')
> (but in many others too, there is no real pattern)
Have you tried enabling reconnects (cp_reconnect=True)? If "select 1"
doesn't work with your database you may also have to pass in custom
> In my desperation, I’m employing for-loops for the SQL queries now. :(
> Since there isn’t much traffic (yet) I would like to just make
> ConnectionPool close the connections and re-open fresh ones, as soon as
> they are necessary.
> Is there some straight-forward way to do that? Or any better approach I’ve
Don't use ConnectionPool at all. Just have a function that does the SQL
connect etc usually normal DB-API, and call it with
conn = db.connect(...)
cursor = conn.cursor()
result = cursor.fetchall()
deferredResult = deferToThread(dbtxn, argForX)
Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python