How to write a non blocking SimpleHTTPRequestHandler ?

Yassine Chaouche yacinechaouche at yahoo.com
Tue Feb 3 04:06:42 EST 2015


Hello Irmen,

> Why? If you have multiple threads serving some requests at the same time, doesn't that
> already achieve your goal? 

Having multiple requests running at a time is one thing. Making them non-blocking is another. That's how I understand it.

> In other words, have you tried what you describe above?

Yes I already tried that, it's in the source code I posted if you look closely you'll see that I am inherting from the mixin. The server still hangs sometime, until I send it the SIGINT signal. It then sort of drops the hanging socket and resumes normal operations.

> (make sure you close the connection correctly or you'll be hogging a thread which may
> eventually make the server non responsive)
> 
> Irmen

I didn't see any such code in the tests that came with the standard python library (which I took as a starting point example to write my script). Maybe it's already taken care of by some lower-level internal stuff ?



More information about the Python-list mailing list