Jason Tackaberry wrote: > On 2008-01-17 13:54, Dirk Meyer wrote: >> This would remove all our 'if isinstance(returnvalue, InProgress)' >> special cases since we know we always get an InProgress object. This >> will make the code much simpler. But we should be carefull when using >> a yield_execution inside a yield_execution in that case. > > How about a special case: if the yield_execution()-decorated function > yields an InProgress object, rather than calling the connected handler > with this, it just post-pones execution of the function until the > InProgress completes. If that doesn't make much sense, here's an example: > > @kaa.yield_execution() > def foo(): > yield 42 > > @kaa.yield_execution() > def bar(): > ip = foo() > yield ip > result = ip.get_result() > ... do some more stuff ...
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.
> Syntactically this is ugly, but we've used this idiom before. You know,
> with Python 2.5 we could do this:
>
> result = yield foo()
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
Dischi
--
Drinking coffee for instant relaxation? That's like drinking alcohol for
instant motor skills.
-- Marc Price
pgpKHfHjNdRWx.pgp
Description: PGP signature
------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-devel
