Multi-threaded SSL

Kris Kowal kris.kowal at gmail.com
Sat Feb 18 00:32:56 EST 2006


Dear Ophidians,

I'm attempting to create an SSL secured, AJAX chat server.  I'm moving
on the hypothesis that I'll need to hang an XMLHttpRequest response
blocking on the server until a new message is ready to be dispatched.
This means that my server must be able to handle many open SSL sockets
in separate threads.

I started with Twisted, but, having looked as far as I can see, SSL is
either not implemented, or not documented for that library.  There are
hints that it's in the works, but that's all.  So, I've moved on.

I'm using PyOpenSSL on a Debian box, and I started with the ActiveState
Cookbook article,
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442473  The SSL
server works very well as suggested in this article.

Starting with this code and adding threads, I've been trying to make
simultaneous HTTP requests operate in parallel on the server.  To test,
I've added in turn busy and sleepy waiting to the GET processing
segment of the request handler.  The threads work fine; every time the
server accepts a connection, it clearly starts accepting connections in
a new thread.  However, the problem runs deeper than I can see.  The
SSL listening socket blocks on accept in all threads until the one open
SSL connection finishes its waiting, responds, and closes.  This means
that I can only have one client waiting for a response at a time.

Is there a limitation of SSL, or this SSL implementation, or something
else preventing me from having multiple connections waiting for
responses simultaneously?

Many thanks,
Kris Kowal




More information about the Python-list mailing list