Simple threaded web-server based on BaseHTTPServer?

Mark Hammond mhammond at skippinet.com.au
Thu Jan 31 20:04:07 EST 2002


Paul Rubin wrote:
> Mark Hammond <mhammond at skippinet.com.au> writes:
> 
>>>I think the best approach (if feasible) is designing the i/o library
>>>to always avoid blocking operations.
>>>
>>But this is a PITA for casual users.  If, for example, you had an IO
>>library where "read()" never blocked, then obviously all the code
>>would need to add support for some sort of notification when the read
>>actually completed and the data is available.  Even then, you would
>>find most programmers then simply issue the non-blocking read call,
>>and immediately wait for the completion notification - meaning you are
>>in the exact same position.
>>
> 
> I mean the library would use nonblocking i/o in its low level
> implementation.  The Python interpreter/microthread scheduler would
> still simulate blocking behavior, so you could code with threads in
> the usual way.  The programmer (writing in Python) wouldn't see or
> care that the underlying system call was nonblocking.

right - that is what Tim was getting at.  You would still need a 
thread-pool of real OS threads that performed the IO for you, so the 
micro-threads can still execute even when the real OS thread doing the 
IO is blocked.  Not trivial :(

Mark.






More information about the Python-list mailing list