Threaded server in python!?

Andrew Bennetts andrew-pythonlist at
Sat Jan 4 03:41:33 CET 2003

On Fri, Jan 03, 2003 at 10:10:53PM +0100, Achim Domma wrote:
> Hi,
> I would like to implement my own http chat server. As far as I know pythons
> threads are not very efficient due to the global interpreter lock. But
> applications like Zope, Webware, ... work fine and they use threads. Am I
> missing something or could somebody post some experiences (good ones and bad
> ones) with threaded, socked based python servers.

Why do you think you need threads to do this?

Using a library like Twisted <>, it's
straightforward to handle multiple sockets, without needing threads.

As a bonus, Twisted has implementations of many common protocols, ready for
you to use and adapt to your problem -- I strongly recommend it, as I
suspect you will find it *much* easier than the alternatives.

If you do use threads though, the GIL still isn't that much of a problem --
it only means one thread can be executing pure python code at once, which is
hardly a limitation on your average single-cpu system.  I/O operations like
reading from a socket happen in C, so they don't hold GIL... besides, why do
you care about the efficiency of software you haven't written yet?  In my
experience, with Twisted, Zope, and even written-from-scratch servers,
Python is more than up to the tasks I've given it.  My problems are always
bugs, not performance :)



More information about the Python-list mailing list