3

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

5
  • mod_wsgi reloads the application without having to restart the server. Perhaps using mod_wsgi would be easier than creating your own web server from scratch. Commented Mar 3, 2010 at 17:57
  • yeah, but I don't want a web/http server, I want a tcp socket server. Can apache/mod_wsgi serve lower than http? Commented Mar 3, 2010 at 18:28
  • @Colin: Your question is confusing. HTTP is a TCP protocol. Handling HTTP sockets is handling TCP sockets. What protocol are you serving? You mention apache/mod_python. Why? Could you clarify your question? Commented Mar 3, 2010 at 18:43
  • @Lott: I just mentioned it because I want hot code reloading, like apache can do. As far as protocols, I'm not using http - just binary data over a raw socket. Commented Mar 3, 2010 at 19:48
  • @Colin: Please update the question to clarify what you want. Please do not add yet more comments. Please update the question so that it's obvious what functionality you're looking for. Commented Mar 4, 2010 at 3:55

2 Answers 2

5

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...).

Sign up to request clarification or add additional context in comments.

1 Comment

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'...
2

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.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.