Multi-threaded SSL

Jean-Paul Calderone exarkun at divmod.com
Sat Feb 18 10:11:36 EST 2006


On 17 Feb 2006 23:37:22 -0800, cowbertvonmoo at gmail.com wrote:
>Thanks Alex.  I hadn't noticed that example.  I gave it a shot and
>still have the synchronization problems.  While this may be because of
>a lack of understanding of twisted threads (again, perhaps I'm just not
>looking in the right places, but even the the API reference is sparse
>of explanation), I strongly suspect that there's something going on at
>a lower level, like the Open SSL wrapper or Open SSL on the system
>level.

You probably couldn't find an explanation of Twisted threads due to the fact that Twisted is implemented almost exclusively without using threads at all.  Aside from the large library of protocol implementations, this is one of its main selling points. ;)

>At this point, I'd just like to know if I should cut my losses
>and try a very rapid polling solution (*cringes*).  Here are my
>attempts:
>
>Twisted SSL Foray:
>http://cixar.com/svn/mage/twisted_ssl_foray.py
>http://cixar.com/websvn/filedetails.php?repname=Cixar&path=%2Fmage%2Ftwisted_ssl_foray.py&rev=0&sc=0

After reading my comment above, hopefully it is clear what is awry in this code.  You cannot use sleep() in a Twisted application and expect anything to work well.  Instead, a scheduling primitive is provided, reactor.callLater(delay, function[, *a[, **kw]]).

However, rather than using the low-level APIs of twisted.web directly, you may be interested in using an implementation of this idea which already exists.  Take a look at <http://divmod.org/trac/wiki/DivmodNevow/Athena>.  The tutorial builds up a web page which does something very like what your code seems to be attempting.

If you pursue the Twisted version, keep in mind the web-dedicated Twisted mailing list you can use as a resource: <http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web>.

Jean-Paul



More information about the Python-list mailing list