LWN: Comments on "A proposal for "rebooted" Python asynchronous I/O support" https://lwn.net/Articles/530919/ This is a special feed containing comments posted to the individual LWN article titled "A proposal for "rebooted" Python asynchronous I/O support". en-us Tue, 30 Sep 2025 09:06:34 +0000 Tue, 30 Sep 2025 09:06:34 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531647/ https://lwn.net/Articles/531647/ tack <div class="FormattedComment"> In which framework were you tasked with debugging a maze of yield froms?<br> <p> This is very different from the callback world of Twisted. The code reads fairly linearly like it would with gevent, except that your exit/entry points are explicit rather than implicit.<br> <p> Having coded with both approaches (that is, explicit yields vs. greenlet-style implicitness) I prefer to be explicit. I rather like the visual cue that signals where my function will suspend and resume and I find this improves debuggability rather than hinders it. IMO, yielding gives you a nice bit of async magic while not violating the principle of least astonishment.<br> </div> Sun, 06 Jan 2013 02:35:32 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531623/ https://lwn.net/Articles/531623/ cmccabe From the <a href="https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git;a=blob_plain;f=README">libabc readme</a>:<p> <pre> > Avoid thinking about main loops/event dispatchers. > - Get your stuff right in the kernel: fds are awesome, expose them > in userspace and in the library, because people can easily integrate > them with their own poll() loops of whatever kind they have. > - Don't hide file descriptors away in your headers. > - Never add blocking kernel syscalls, and never add blocking library > calls either (with very few exceptions). Userspace code is primarily > asynchronous around event loops, and blocking calls are generally > incompatible with that. > - Corollary of that: always O_NONBLOCK! </pre> I can't think of any library I have used in the past few years that has used a glib-based main loop. So basically, if your library depends on some event loop framework... you're doing it wrong.<p> Sat, 05 Jan 2013 19:53:53 +0000 Self-fulfilling prophecy https://lwn.net/Articles/531461/ https://lwn.net/Articles/531461/ man_ls I would have very much appreciated an explicit Python mention, e.g.: <blockquote> Let the discussion about the color of <a href="http://orangecow.org/pythonet/sketches/arthurtw.htm">Arthur "Two Sheds" Jackson</a>'s second shed begin! </blockquote> But bikeshedding? Heresy! Fri, 04 Jan 2013 11:53:46 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531458/ https://lwn.net/Articles/531458/ smurf <div class="FormattedComment"> Given that a model like gevent's is (a) a whole damn lot more natural to code to than all that "yield from" stuff, and (b) explicitly out of scope, I'd have to agree to the "rigid and obsolete" comment.<br> <p> Debugging a maze of "yield from"s and/or explicitly registered callbacks is a *major* PITA. Been there, done that, given up, and re-implemented a couple of ten thousand lines with gevent instead of Twisted.<br> <p> Fortunately, implementing a Twisted reactor on top of gevent has already been done, so the migration can be done in steps and is rather painless.<br> <p> I am fairly sure that the same thing will be done for this PEP, once it's moderately final.<br> </div> Fri, 04 Jan 2013 11:23:15 +0000 Self-fulfilling prophecy https://lwn.net/Articles/531398/ https://lwn.net/Articles/531398/ JanC_ <p>And of course this was meant to read like this:</p> <blockquote>You forget that this particular BDFL named his programming language after <a rel="nofollow" href="https://en.wikipedia.org/wiki/Monty_Python">a comedy group</a></blockquote> <p><small>(Can we get a post editor, please? ;) )</small></p> Thu, 03 Jan 2013 22:23:20 +0000 Self-fulfilling prophecy https://lwn.net/Articles/531397/ https://lwn.net/Articles/531397/ JanC_ <div class="FormattedComment"> &lt;p&gt;You forget that this particular BDFL named his programming language after &lt;a href=""&gt;a comedy group&lt;/a&gt;&lt;/p&gt;<br> </div> Thu, 03 Jan 2013 22:18:14 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531338/ https://lwn.net/Articles/531338/ intgr <div class="FormattedComment"> In "advance" of what? This isn't a specification, this is a proposal, and it's not ready yet.<br> <p> You are kindly invited to collaborate and improve it.<br> <p> </div> Thu, 03 Jan 2013 18:12:38 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531092/ https://lwn.net/Articles/531092/ wahern <div class="FormattedComment"> FWIW, I believe Python coroutines will work much like Javascript generator trampolines: <a href="http://www.neilmix.com/2007/02/07/threading-in-javascript-17/">http://www.neilmix.com/2007/02/07/threading-in-javascript...</a><br> <p> </div> Tue, 01 Jan 2013 00:10:42 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531088/ https://lwn.net/Articles/531088/ wahern <div class="FormattedComment"> I think you misunderstood what I was saying. To understand the fundamental problem in the CPython (and Jython) VM, just think about the difference between CPython and Stackless. You can't `yield from' inside a new function invocation because of the way call frames are implemented in CPython. Only the callee of a `yield from' statement can yield. But you can explicitly stack yield froms in a call chain. Kinda messy, but it's a fundamental limitation of CPython.<br> <p> Coroutines in languages like Lua are implemented more like threads, so coroutine semantics aren't limited to a single callee invocation. In Lua, invocation C in A-&gt;B-&gt;C can yield, even though coroutine resumption began in A. In CPython, when resuming A only A can yield. A can, however, _explicitly_ invoke B as a coroutine. But B (perhaps a library call) can't hide the details. A needs to adorn it's call to B in order to get coroutine semantics. Again, not so in Lua or some other languages.<br> <p> </div> Mon, 31 Dec 2012 23:47:58 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/531085/ https://lwn.net/Articles/531085/ Arach <div class="FormattedComment"> Rigid and obsolete in advance.<br> </div> Mon, 31 Dec 2012 22:53:10 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530988/ https://lwn.net/Articles/530988/ tack <div class="FormattedComment"> You've misunderstood the PEP. Coroutines are implemented using generators, yes, but they can be arbitrarily nested (within runtime stack depth limits of course). In other words, coroutine A can "yield from" coroutine B which can "yield from" coroutine C and so on. If C yields a Future object, the stack unravels -- through B and A -- and the coroutine scheduler will resume C's execution when the Future it yielded is done.<br> </div> Sun, 30 Dec 2012 04:36:54 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530986/ https://lwn.net/Articles/530986/ wahern <div class="FormattedComment"> From the PEP Guido says they're basically just generators underneath, which means these aren't like more modern coroutine implementations which can yield from sub-subroutine invocations. Being restricted to the first-level invocation will hardly remove the necessity for callbacks in high-level application code, unfortunately.<br> <p> This is why I much prefer Lua. It might not have the huge library, but at least the VM is done right.<br> <p> </div> Sun, 30 Dec 2012 03:35:32 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530978/ https://lwn.net/Articles/530978/ ppisa <div class="FormattedComment"> I like proposal and please, invest time to to ensure good compatibility with libevent-2 main loop and consider even its buffer events. I think that that library is good candidate for generic mainloop for most of applications.<br> <p> But there is need to live with GLIB based mainloop as well. Its interface is so rigid and unfortunate that only option for other GUI systems (like Qt) was to switch to GLIB mainloop when GLIB based loop libraries are considered for them. I hope that GLIB community would invest time to that problem some day but it cannot be done without API level compatibility break.<br> <p> You can look at my ul_evpoll effort as a source for some ideas too. It started in libevent-1 days as an solution to write libraries requiring system level events registration and compatibility with GLIB and yet to be able to switch to libevent. Then the project little extended to provide own implementation of select, poll, epoll and winevent mechanism and ability to plug-in into GLIB, libevent-1 and libevent-2 based applications.<br> <p> The ul_evpoll library is part of uLAN and OrtCAN SF.net repositories<br> * <a href="http://ulan.sourceforge.net/">http://ulan.sourceforge.net/</a><br> * <a href="http://ulan.git.sourceforge.net/git/gitweb-index.cgi">http://ulan.git.sourceforge.net/git/gitweb-index.cgi</a><br> I have prepared snapshot for simple standalone testing<br> * <a href="http://cmp.felk.cvut.cz/~pisa/ulan/ul_evpoll/ul_evpoll-121230.tar.gz">http://cmp.felk.cvut.cz/~pisa/ulan/ul_evpoll/ul_evpoll-12...</a><br> Documentation - qute short, written in a hurry and with many sins against English language<br> * <a href="http://cmp.felk.cvut.cz/~pisa/ulan/ul_evpoll/doc/ulevpoll.html">http://cmp.felk.cvut.cz/~pisa/ulan/ul_evpoll/doc/ulevpoll...</a><br> <p> </div> Sun, 30 Dec 2012 00:33:29 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530964/ https://lwn.net/Articles/530964/ man_ls Probably van Rossum said the quoted sentence as a joke, and my humor detector is on holidays too. It just sounded a bit harsh coming from a "benevolent dictator" to me. Sat, 29 Dec 2012 19:02:34 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530963/ https://lwn.net/Articles/530963/ corbet Bear in mind that this PEP comes after a few months of quite intense conversation. Have a look at the <a rel="nofollow" href="http://mail.python.org/pipermail/python-ideas/">python-ideas list</a> starting in October. It's not like the conversation is starting now, in the middle of the holiday lull. Sat, 29 Dec 2012 18:52:39 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530960/ https://lwn.net/Articles/530960/ man_ls Yes, you are right on that respect. Not too much discussion though, especially for such an interesting topic. Python lost momentum in the async server area when it could have led the pack. Sat, 29 Dec 2012 18:38:41 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530959/ https://lwn.net/Articles/530959/ augustz <div class="FormattedComment"> The comments look constructive and on-point to me. <br> <p> <p> <p> </div> Sat, 29 Dec 2012 17:48:56 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530950/ https://lwn.net/Articles/530950/ tack <div class="FormattedComment"> With a model like Twisted's, you have a twisty little maze of callbacks.<br> <p> So one of the primary drivers of this PEP is coroutines, which let us solve the callback hell problem seen in languages like Javascript (especially with node.js). To standardize on coroutines used for async IO, you also need to standardize a bunch of other things like a Future-like object and a minimal event loop.<br> <p> Once these things are defined and codified, libraries like Twisted and Kaa can conform to them, and this just might, if we play our cards right, pave the way for async library interoperability in Python land. Today each library takes a different and incompatible approach.<br> <p> Also Twisted's API is not PEP8 compliant. :)<br> </div> Sat, 29 Dec 2012 16:26:02 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530948/ https://lwn.net/Articles/530948/ njs <div class="FormattedComment"> Twisted is seriously awesome. But I would be very surprised to see it end up in the standard library. Just to start with, twisted as a whole is a huge sprawling mess of variable quality code, so you'd have to extract some small pieces (just the reactor interface?), and even those interfaces probably have stuff in them that you'd want to clean up given how many years its been since they were first designed. And twisted relies heavily on zope-style interfaces, which have been rejected from the stdlib before. And twisted is still a long way from running on Python 3.<br> </div> Sat, 29 Dec 2012 14:32:58 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530946/ https://lwn.net/Articles/530946/ marduk <div class="FormattedComment"> I didn't read the entire PEP but it seems that Twisted, ZeroMQ and Tornado were thought of and can easily implement the interface for the PEP. It seems that one of the goals is to have a a common interface (think wsgi or the db-api) while a second goal is to have a reference implementation included in the standard library.<br> </div> Sat, 29 Dec 2012 13:30:53 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530945/ https://lwn.net/Articles/530945/ robert_s <div class="FormattedComment"> "Let the bikeshedding begin!"<br> <p> You could say the same thing about any PEP. But miraculously a lot of them get accepted.<br> </div> Sat, 29 Dec 2012 13:28:03 +0000 Self-fulfilling prophecy https://lwn.net/Articles/530944/ https://lwn.net/Articles/530944/ man_ls <blockquote> Let the bikeshedding begin! </blockquote> Not a very good start for a healthy discussion. As could be expected there are to date only a handful of messages in <a href="http://thread.gmane.org/gmane.comp.python.devel/136422">the thread</a>. Sat, 29 Dec 2012 12:19:51 +0000 A proposal for "rebooted" Python asynchronous I/O support https://lwn.net/Articles/530941/ https://lwn.net/Articles/530941/ cglass <div class="FormattedComment"> I'll go ahead and ask the obvious question here, apologies if this seems obvious to people more familiar with the topic at hand:<br> Why not twisted? Why reimplement the same functionality with a slightly different interface?<br> It certainly isn't perfect, but I would be interested in understanding the reasons.<br> </div> Sat, 29 Dec 2012 11:38:35 +0000