Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85147
| References | (5 earlier) <b6cb0fcb-9934-41b6-a8f6-902d26f2588c@googlegroups.com> <mailman.18421.1422961678.18130.python-list@python.org> <87r3u7grd3.fsf@elektro.pacujo.net> <e6d081df-1db0-41a3-905c-e3c2845d5dda@googlegroups.com> <87iofjglbg.fsf@elektro.pacujo.net> |
|---|---|
| Date | 2015-02-04 01:03 +1100 |
| Subject | Re: How to write a non blocking SimpleHTTPRequestHandler ? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18424.1422972220.18130.python-list@python.org> (permalink) |
On Wed, Feb 4, 2015 at 12:45 AM, Marko Rauhamaa <marko@pacujo.net> wrote: >> 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. > > Now I think you might have some misconceptions about nonblocking > networking I/O. Nonblocking I/O is done using asynchronous, or > event-driven, programming. Your code reacts to external stimuli, never > blocking, mostly just sleeping. The reactions are defined in callback > routings, aka listeners, aka event handlers. Not strictly true - that's just one convenient way of doing things. A callback/event-handler structure lets you write a bunch of listeners that coexist effortlessly, but it's not the only way to do non-blocking I/O, and it's certainly not an intrinsic part of the concept. That said, though, it is a VERY convenient way to lay things out in the code. The Pike system I offered, and most of the older multiplexed-I/O systems I've used, did work that way. It just isn't something that non-blocking necessarily implies. >> I don't know why wouldn't that be possible with python stdlib ? > > It is possible using the low-level facilities. However, the traditional > high-level facilities are built on multithreading, which (as a rule) is > based on blocking I/O. Multithreading is another way to cope with the same problem of wanting to deal with different sockets on a single CPU, but I don't think it's inherently a part of any of Python's own high-level facilities - not that I can think of, at least? However, in terms of common programming models, yes, multithreading+blocking I/O is an effective way to write code, and will therefore be commonly used. I wish more people had grown up on OS/2 instead of (or as well as) Windows or Unix. Threading is not such a bugbear as a lot of people seem to think. Yes, some platforms have traditionally had poor implementations, and to be sure, you don't want to mix threading and forking without a *lot* of care, but threads aren't inherently bad. They're a useful tool in the toolbox. Sometimes non-blocking I/O is the right thing to do; sometimes threads suit the problem better; other times, something else again. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to write a non blocking SimpleHTTPRequestHandler ? Amirouche Boubekki <amirouche.boubekki@gmail.com> - 2015-02-02 10:07 +0000
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 01:08 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Marko Rauhamaa <marko@pacujo.net> - 2015-02-03 11:27 +0200
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 02:47 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Chris Angelico <rosuav@gmail.com> - 2015-02-03 21:54 +1100
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 03:04 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Chris Angelico <rosuav@gmail.com> - 2015-02-03 22:07 +1100
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 03:23 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Marko Rauhamaa <marko@pacujo.net> - 2015-02-03 13:35 +0200
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 04:56 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Marko Rauhamaa <marko@pacujo.net> - 2015-02-03 15:45 +0200
Re: How to write a non blocking SimpleHTTPRequestHandler ? Chris Angelico <rosuav@gmail.com> - 2015-02-04 01:03 +1100
Re: How to write a non blocking SimpleHTTPRequestHandler ? Marko Rauhamaa <marko@pacujo.net> - 2015-02-03 16:20 +0200
Re: How to write a non blocking SimpleHTTPRequestHandler ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-02-03 20:25 -0500
Re: How to write a non blocking SimpleHTTPRequestHandler ? Chris Angelico <rosuav@gmail.com> - 2015-02-04 00:21 +1100
Re: How to write a non blocking SimpleHTTPRequestHandler ? Amirouche Boubekki <amirouche.boubekki@gmail.com> - 2015-02-03 14:09 +0000
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-03 06:50 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Filadelfo Fiamma <philosganga@gmail.com> - 2015-02-03 16:03 +0100
Re: How to write a non blocking SimpleHTTPRequestHandler ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-03 16:39 +0000
Re: How to write a non blocking SimpleHTTPRequestHandler ? Yassine Chaouche <yacinechaouche@yahoo.com> - 2015-02-08 06:13 -0800
Re: How to write a non blocking SimpleHTTPRequestHandler ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-03 12:10 +0000
csiph-web