[IPython-dev] Musings: syntax for high-level expression of parallel (and other) execution control

Hans Meine hans_meine@gmx....
Tue Sep 8 04:15:07 CDT 2009


On Sunday 06 September 2009 09:14:46 Prabhu Ramachandran wrote:
> Thanks for the interesting links and thread.  Just FYI, last year I had
> occasion to solve, relatively elegantly, a set of pretty sticky problems
> for mayavi2 using decorators and generators.  [...]
> They allow us to do relatively simple but neat things very elegantly.

Seconded.

> The Kamaelia project (http://www.kamaelia.org) is also very interesting
> for its use of generators, microprocesses, components and very
> specifically concurrency.

Let me throw kaa into the pot, which is a set of libraries for media 
programming, but kaa.base contains really interesting coroutine-stuff!
Let me quote http://doc.freevo.org/2.0/Kaa:
> The kaa framework includes a mainloop facility with an API for signals and
> callbacks, timers, process and thread management, file descriptor monitoring
> (with INotify support), inter-process communication, as well as a rich,
> practically magical API for asynchronous programming (see
> http://doc.freevo.org/2.0/SourceDoc/Async)

Maybe the threaded decorator is similar to what Fernando has in mind:
(I thought I mentioned kaa here before, but I guess I did not give any code 
examples..)

@kaa.threaded()
def do_blocking_task():
   [...]
   return 42

@kaa.coroutine()
def do_something_else():
   try:
      result = yield do_blocking_task()
   except:
      print "Exception raised in thread"
 
   print "Thread returned", result

Have a nice day,
  Hans



More information about the IPython-dev mailing list