<p dir="ltr"><br>
On 17 Mar 2013 11:35, "Steven Hazel" <<a href="mailto:sah@awesame.org">sah@awesame.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I'm one of the authors of monocle (<a href="https://github.com/saucelabs/monocle">https://github.com/saucelabs/monocle</a>), an async Python programming framework with a blocking look-alike syntax based on generators. We've been using monocle at my startup Sauce Labs, and I used its predecessor on a small team at BitTorrent. I think it's met with some amazing success vs. similar projects using threads. In about five years of working with teams with some members who haven't always understood monocle very well, we've never written a deadlock, for example.<br>

><br>
> I've been keeping up with PEPs and skimming python-ideas discussions about concurrency-related features in Python, and feeling unsure about how best to jump into the conversation. Today it occurred to me that sooner is better and I should just get all my various opinions out there in case they're helpful.<br>

><br>
> First of all, I want to reiterate: while I have mainly criticism to offer, it is only intended to be helpful. I don't have a lot of time to devote to this myself, so I'm trying to do what I can to be useful to those who do.<br>

><br>
> I think I'll take this one PEP at a time, and start with the easiest one.<br>
><br>
> PEP 3148 - Futures</p>
<p dir="ltr">This PEP isn't new, it was released in Python 3.2, and is available for 2.x as a backport on PyPI.</p>
<p dir="ltr">Cheers,<br>
Nick.<br></p>
<p dir="ltr">><br>
> First, I like the idea of this PEP. I think it'll improve interoperability between async frameworks in Python.<br>
><br>
> I believe the name "future" is a poor choice. After many years of explaining this concept to programmers, I've found that its various abstract-conceptual names do a lot to confuse people. Twisted's "deferred" is probably the worst offender here, but both "future" and "promise" also make this very simple construct sound complicated, and it's a crime.<br>

><br>
> There are two ways I've found to explain this that seem to keep people from getting confused:<br>
><br>
> The first is, call it a "callback registry". Many programmers are familiar with the idea of passing callbacks into a function. You just explain that here, instead of taking the callbacks as parameters, we return a callback registry object and you can add your callbacks there. (If the operation is already done they'll just get called when you add them.)<br>

><br>
> The second is a variant on that: say that this function, instead of taking a callback as a parameter, returns its callback. That sounds useless, but fortunately the callback it returns is a callable object, and it also has an "add" method that lets you add functions that it will call when called back. So it's a callback that you can manipulate to do what you want. (This is what we do in monocle: <a href="https://github.com/saucelabs/monocle/blob/master/monocle/callback.py">https://github.com/saucelabs/monocle/blob/master/monocle/callback.py</a>)<br>

><br>
> These approaches, by focusing on the simple and familiar idea of callbacks, do a lot to eliminate confusing ideas about communicating with the future of the process.<br>
><br>
> Finally, I'm not sure I get the point of the Executor class in PEP 3148. It seems to me that any real implementation of that class needs a call_later method for scheduling operations, and a way of connecting up to event-based IO APIs. I don't really understand what Executor would be good for.<br>

><br>
> Thanks for reading.<br>
><br>
> -- <br>
> Steven Hazel<br>
> Sauce Labs Cofounder and VP Product<br>
> <a href="http://saucelabs.com/">http://saucelabs.com/</a><br>
> work: <a href="mailto:sah@saucelabs.com">sah@saucelabs.com</a><br>
> other: <a href="mailto:sah@awesame.org">sah@awesame.org</a><br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="http://mail.python.org/mailman/listinfo/python-ideas">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
><br>
</p>