socketServer questions

Christopher Subich csubich.spam.block at spam.subich.block.com
Fri Oct 7 14:10:33 EDT 2005


Paul Rubin wrote:
> rbt <rbt at athop1.ath.vt.edu> writes:
> 
>>1. Do I need to use threads to handle requests, if so, how would I
>>incorporate them?  The clients are light and fast never sending more
>>than 270 bytes of data and never connecting for more than 10 seconds
>>at a time. There are currently 500 clients and potentially there
>>could be a few thousand... how high does the current version scale?
> 
> open for very long.  If you want to have longer-running connections
> open simultaneously, you need some type of concurrency such as threads.
> But then you have to write the code differently, to serialize the
> log recording.  
> 
> You probably should get a copy of "Python Cookbook" which explains the
> basics of multi-threaded programming, if you have to ask a question

Or take a look at non-threaded ways of doing non-blocking IO; I've 
personally used the Twisted libraries and they work decently without 
manual thread overhead [indeed, the default reactor uses select, and 
there's a version for 'nix systems that uses poll].

Either way will work, it just depends on how deeply you want to 
integrate the network functionality into the code.  As someone else said 
(paraphrased, an apologies for stealing the quote; a Google search isn't 
bringing it up), "You don't use Twisted, you provide Twisted callbacks 
to use you."



More information about the Python-list mailing list