module similar to Perl Net::Server

Andrew Bennetts andrew-pythonlist at
Tue Feb 4 13:43:15 CET 2003

On Tue, Feb 04, 2003 at 02:56:49PM +0300, rayed wrote:
> I need a database access, and I don't want to block other connections 
> when querying the database.

That's ok.  You can use twisted.enterprise.adbapi, which automatically wraps
a DB-API 2.0 module into an asynchronous interface (it does the DB
interactions in threads, and then fires an event in the main loop).

Or if you prefer, you could use twisted.internet.threads.deferToThread,
which will run a function in a thread, and fire a callback on a Deferred
when done.

Twisted is asynchronous, but it gives you convenient ways to work with
blocking code when necessary.


More information about the Python-list mailing list