On 2008-01-17 14:22, Dirk Meyer wrote:
> I simple way to do this without added extra logic to a Signal is to
> _not_ call the first next() right now but wait at least one main loop
> iteration. This will force the return of an InProgress object.

But this doesn't work in the case where the decorated function doesn't
yield anything but just returns something.  It also incurs an
unnecessary latency to a function call that could well complete
immediately.  I'd rather do something synchronously if I can.

Signal.emit_deferred conceptually is pretty straightforward.  I favor
that over your suggestion.

> I know, but what about exceptions?
>
> @kaa.yield_execution()
> def foo():
> yield 42 / 0
>
> @kaa.yield_execution()
> def bar():
> ip = foo()
> yield ip
> result = ip.get_result()
> ... at this point get_result will raise DevisionByZero

Exceptions can be handled like this:

   try:
      result = yield foo()
   except DivisionByZero:
      ...

This is a really nice syntax actually.  See
http://docs.python.org/whatsnew/pep-342.html



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to