[Twisted-Python] connection pool

Tjerk.Kusters at imtech.nl Tjerk.Kusters at imtech.nl
Thu Jan 17 02:50:55 EST 2008

>> I have build a webserver with Twisted 2.4 with imports of the following:
>>  from twisted.web import resource, static, server, twcgi
>>  from twisted.internet import reactor
>> I'm adding several mods as child to the root with:
>>  root = static.File(settings.getSetting("html_directory"))
>>  root.putChild(mods.getPath(), mods
>> The mods are classes like
>>  class module(resource.Resource):
>>    def render_GET(self, request):
>>       # do something
>> The reactor is started as:
>>  reactor.listenTCP(_port, server.Site(root))
>>  reactor.run( )
>> Some of the GET request in the mods can take some time to complete. In
>> current situation other request to the server have to wait on this
>> Is it possible to make soms kind of a thread/connection pool so that
>> then one request can be handled at the same time?
>> Regards,
>> Tjerk
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>Yes it is possible to use a thread pool, in fact twisted comes with
>one. However, how you use it depends on what is taking so long for
>- if it's database calls then consider using twisted.enterprise.adbapi
>- if it's python code taking so long then consider breaking your code
>into shorter snippets that yield control back to twisted periodically
>so that other requests don't get ignored
>- if it's network code then make sure you're using Deferred's properly
>- http://twistedmatrix.com/projects/core/documentation/howto/defer.html

The call can take some time because I have to wait on a response from a
CORBA call.

I have looked at deferred's, but can not see how this can be used to solve
the problem. The render_GET(self, request) can only return when there is an

Is there a way to make twisted web to handle multi connections at the same


More information about the Twisted-Python mailing list