29 Oct 2001 thayer   » (Observer)

Python Networking

I've discovered several important deficiencies in some python networking classes. The problem is in the structure of both medusa/asyncore and the regular python socketserver plus basehttpserver.

Namely a request object can't declare that (a) it doesn't want to handle the request and the server should continue (b) the server should stop right there.

Both these actions are important for fork()ing. If the request handler forks, you have two processes that both want to reply to the same socket. There libraries are structured to support always forking or threading, but not a mixture of either determined within the request handler itself.

Also, although the medusa base class is smart enough in asyncore and asynchat to handle a special ExitNow exception, the HTTP server classes built on top are rude and catch all excepts. Someone using these can't raise an ExitNow because it's returned as a 500 or other HTTP error.

These problems have made it impossible for me to build a workable XMLRPC/SSL server which forks. Alas, I'm fairly happy with most of the base classes / modules. I'm going to have to add some lines to these packages and send out patches.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!