How to write a non blocking SimpleHTTPRequestHandler ?

Amirouche Boubekki amirouche.boubekki at gmail.com
Tue Feb 3 09:09:51 EST 2015


> The standard library and nonblocking can't be used in the same sentence.

python 2.x stdlib has no high level support of *async* code. There is
trollius library that ports asyncio to py2 though.

I was a bit quick in my first anwser. What you want is to prevent the
socket to wait indefinetly for data (based on strace output) which is done
with socket.setblocking/settimeout [1]. asynchronous (asyncio) is something
else, and you would still need to handle blocking I think.

There is contentbrowser [2] which is somekind of web proxy.

IMO, python 2 -> python 3 is not a big leap. Some things are better in
python 3.


[1] https://docs.python.org/2/library/socket.html#socket.socket.setblocking
[2] https://bitbucket.org/david/contentbrowser/src





On Tue Feb 03 2015 at 2:00:27 PM Yassine Chaouche
<yacinechaouche at yahoo.com.dmarc.invalid> wrote:

> On Tuesday, February 3, 2015 at 12:35:32 PM UTC+1, Marko Rauhamaa wrote:
>
> > So far I've been happy with select.epoll(), socket.socket() and ten
> > fingers.
> > Marko
>
> There's already software written to take care of much of the HTTP stuff
> protocol stuff, the headers etc. I wouldn't rewrite it. I prefer to monkey
> patch parts of existing code rather then rewrite all of it.
>
> But your comment is interesting because, as I understand it, a
> non-blocking web server is simply a matter of setting timeouts on sockets,
> catch the exceptions and move on. I don't know why wouldn't that be
> possible with python stdlib ?
>
>
> > The standard library and nonblocking can't be used in the same sentence.
>
> ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150203/3ac295c9/attachment.html>


More information about the Python-list mailing list