views:

241

answers:

2

Hi, I'm looking for a python socket server framework - not to handle http, but to handle tcp sockets. I've done it myself, but adding all the features is tedious. This framework would handle thread pooling, socket setup, signal handling, etc.

A big feature is code-reloading. If I use apache/mod_python, or django, or whatever, I don't have to restart the server to get it to use new/changed code. Anybody know how that's done?

thanks!

Colin

+2  A: 

Twisted is the usual suspect. Reloading in the case of mod_wsgi is easy since only the WSGI server needs to be restarted, not the whole web server (not that restarting the web server is all that hard, mind you...).

Ignacio Vazquez-Abrams
Yeah, I might have to go that route. I just didn't want to get all asynchronous. I'm perfectly happy with synchronous handling, just wanted to get a bunch of server framework stuff 'for free'...
Colin
+1 for twisted.
nosklo
+2  A: 

Use Apache, mod_wsgi in daemon mode and follow these guidelines.

Update: I mentioned Apache because you did in your question - I assumed you were talking about a web application that also acted as a socket server.

The Python library has socket servers (see the documentation). AFAIK you can't do hot code reloading in Python without potentially losing packets, for that you would need something specifically designed for hot code reloading, such as Erlang, or else just have a dumb socket receiver which receives and queues packets, and a smarter backend process which does code reloading and packet handling. In that case, your receiver would be acting as a proxy.

Vinay Sajip
I thought apache was an http server. Can it be used to serve tcp sockets?
Colin