[Twisted-Python] threading issues with DB connection pooling and ReconnectingClientFactory

Andreas Poisel a.poisel at acat.cc
Wed Dec 14 06:33:10 EST 2005


thank you for your comments.

* Andrew Bennetts <andrew-twisted at puzzling.org> [051214 02:00]:

> If you are using any Twisted objects, such as transports, in a thread, you are
> doing something wrong.

I'm really sorry, my assumptions were totally wrong.

>     # run queryDB in a thread
>     deferred = deferToThread(queryDB)

I'm using dbapi to query the database and now I understand that I'm back
in the main thread when the query results are available.

Now I think my problem (no valid transport object after reconnect) has
nothing to do with threads.

I'm using task.LoopingCall() to query the database frequently.  After
reconnecting to the server, the protocol object which is in charge for
the looping calls to the database does not reconnect to the server
automatically.  I think I have to stop() and start() the looping calls
after reconnecting to get a working transport again.

> The twisted.enterprise.adbapi module works much like this.

Sorry for wasting your time but you nevertheless helped me "getting"
some aspects of twisted.

Regards, Andi

More information about the Twisted-Python mailing list