Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'url:bitbucket': 0.05; 'socket': 0.07; 'http': 0.09; 'rewrite': 0.09; 'subject:How': 0.10; 'python': 0.11; "wouldn't": 0.14; '->': 0.16; '[1].': 0.16; 'blocking': 0.16; 'imo,': 0.16; 'non-blocking': 0.16; 'stuff,': 0.16; 'subject:non': 0.16; 'think.': 0.16; 'prevent': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'bit': 0.19; 'else,': 0.19; 'written': 0.21; 'feb': 0.22; '2.x': 0.24; 'headers': 0.24; 'tue': 0.24; "i've": 0.25; '>': 0.26; 'to:2**1': 0.27; '[1]': 0.29; 'patch': 0.29; '[2]': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'exceptions': 0.31; 'though.': 0.31; 'stuff': 0.32; 'url:python': 0.33; 'comment': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'url:listinfo': 0.36; 'possible': 0.36; 'url:org': 0.36; 'level': 0.37; 'server': 0.38; 'url:library': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'catch': 0.60; 'matter': 0.61; 'simply': 0.61; 'first': 0.61; 'high': 0.63; '2015': 0.84; 'asynchronous': 0.84; 'subject:skip:S 20': 0.91; 'ports': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:from:date:message-id:subject:to :content-type; bh=kaZmXFSSgX55ELK+ZcVipg4H9b1vG5hPKXGnvK8L0Xo=; b=Ab9pnz+nYElhxV1RefAtTV3dVqoBoRQfndjwGwfK0P8buyn0xL1iEldPsBbOQs7PoG 7mbXtTV9MPl3hOgwQbYi2CeVNwbi3ze5o9XKbgdwNYMODNWezGfsq4HjfNe48F2AQzU4 7PhU/PGzkv9PlPO9FmmxNfvU4MepZUmGZiUEBlf6zmtNQa+kkaG5HQovhjAEZ7a3+XIC 8UyvoaIre4yR9w/jlvym7Hhz8+L1zlKIbt1f6Mbg5C3hfcJHUW2Ti9LlCupYlOXUA978 UhmR6yxZWwdinuXcQcMhkw+IBjAHEJ/iSP2muqA6CcIvfcsK32tqQbOMrms/UowKdoIl 06Xw== X-Received: by 10.152.9.170 with SMTP id a10mr24458360lab.1.1422972592465; Tue, 03 Feb 2015 06:09:52 -0800 (PST) MIME-Version: 1.0 References: <47031e69-e94d-4257-8c7d-e7c00a543634@googlegroups.com> <874mr3ibve.fsf@elektro.pacujo.net> <87r3u7grd3.fsf@elektro.pacujo.net> From: Amirouche Boubekki Date: Tue, 03 Feb 2015 14:09:51 +0000 Subject: Re: How to write a non blocking SimpleHTTPRequestHandler ? To: Yassine Chaouche , python-list@python.org Content-Type: multipart/alternative; boundary=001a1132f49ae62fa7050e2f9f53 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 111 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422973045 news.xs4all.nl 2875 [2001:888:2000:d::a6]:43642 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85150 --001a1132f49ae62fa7050e2f9f53 Content-Type: text/plain; charset=UTF-8 > 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 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 > --001a1132f49ae62fa7050e2f9f53 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> The st= andard library and nonblocking can't be used in the same sentence.
<= /div>

python 2.x stdlib has no high level suppo= rt of *async* code. There is trollius library that ports asyncio to py2 tho= ugh.

I was a bit q= uick in my first anwser. Wha= t you want is to prevent the socket to wait indefinetly for data (based on = strace output) which is done with socket.setblocking/settimeout [1]. asynch= ronous (asyncio) is something else, and you would still need to handle bloc= king 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.

=


On Tue Feb 03 2015 at 2:00:27 PM Yassine Chaouche <yacinec= haouche@yahoo.com.dmarc.invalid> wrote:
https://mail.python.org/mailman/listinfo/python-list
--001a1132f49ae62fa7050e2f9f53--