I need to develop an application in Python handling a few thousand of persistent TCP connection in parallel. Clients connected to the server at bootstrap and send some message (in binary format) from time to time. The server also send both in reply to clients' message and asynchronously some other binary messages. Basically it is a persistent connection initiated by the client because I have no way to reach clients that are behind a NAT.
The question is: which is the libraries/framework i shall consider for this task. Spawning a thread for each client is not an option. I'm not aware of thread pool library for python. I also recently discovered gevent. Which other options do I have?
'greenlets' is a leighweight concurrency package. See http://greenlet.readthedocs.org/en/latest/. Besides
greenlets
, you might also want to considermultiprocessing
. See http://docs.python.org/2/library/multiprocessing.html.