<div class="gmail_quote">On Sun, Oct 14, 2012 at 12:27 AM, Daniel McDougall <span dir="ltr"><<a href="mailto:daniel.mcdougall@liftoffsoftware.com" target="_blank">daniel.mcdougall@liftoffsoftware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(This is a response to GVR's Google+ post asking for ideas; I<br>
apologize in advance if I come off as an ignorant programming newbie)<br>
</blockquote><div> <br>-- snip snip snip --<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
import async # The API of the future ;)<br>
async.async_call(retrieve_log_playback, settings, tws,<br>
mechanism=multiprocessing)<br>
# tws == instance of tornado.web.WebSocketHandler that holds the open connection<br>
</blockquote><div><br>Is this a CPU-bound problem?<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My opinion is that the goal of any async module that winds up in<br>
Python's standard library should be simplicity and portability. In<br>
terms of features, here's my 'async wishlist':<br>
<br>
* I should not have to worry about what is and isn't pickleable when I<br>
decide that a task should be performed asynchronously.<br></blockquote><div><br>Certainly. My above question is important, because this should only matter for IPC.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* I should be able to choose the type of event loop/async mechanism<br>
that is appropriate for the task: For CPU-bound tasks I'll probably<br>
want to use multiprocessing. For IO-bound tasks I might want to use<br>
threading. For a multitude of tasks that "just need to be async" (by<br>
nature) I'll want to use an event loop.<br></blockquote><div><br>Ehhh, maybe. This sounds like it confounds the tools for different use cases. You can quite easily have threads and processes on top of an event loop; that works out particularly nicely for processes because you still have to talk to your processes.<br>
<br>Examples:<br><br>twisted.internet.reactor.spawnProcess (local processes)<br>twisted.internet.threads.deferToThread (local threads)<br>ampoule (remote processes)<br><br>It's quite easy to do blocking IO in a thread with deferToThread; in fact, that's how twisted's adbapi, an async wrapper to dbapi, works.<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* Any async module should support 'basics' like calling functions at<br>
an interval and calling functions after a timeout occurs (with the<br>
ability to cancel).<br>
* Asynchronous tasks should be able to access the same namespace as<br>
everything else. Maybe wishful thinking.<br></blockquote><div><br>With twisted, this is already the case; general caveats for shared mutable state across threads of course still apply. Fortunately in most Twisted apps, that's a tiny fraction of the total code, and they tend to be fractions that are well-isolated or at least easily isolatable.<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* It should support publish/subscribe-style events (i.e. an event<br>
dispatcher). For example, the ability to watch a file descriptor or<br>
socket for changes in state and call a function when that happens.<br>
Preferably with the flexibility to define custom events (i.e don't<br>
have it tied to kqueue/epoll-specific events).<br></blockquote><div><br>Like connectionMade, connectionLost, dataReceived etc?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks for your consideration; and thanks for the awesome language.<br>
<br>
--<br>
Dan McDougall - Chief Executive Officer and Developer<br>
Liftoff Software ✈ Your flight to the cloud is now boarding.<br>
904-446-8323<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" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>cheers<div>lvh</div><br>