Jason Tackaberry wrote: > 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.
That is ugly anyway. > It also incurs an unnecessary latency to a function call that could > well complete immediately. I'd rather do something synchronously if > I can. I hope you can. Doing the async stuff was not easy to test. :) > Signal.emit_deferred conceptually is pretty straightforward. I favor > that over your suggestion. InProgress is a different kind of Signal. We will _always_ have only one call back. So in fact, connect acts like connect_once. So if the signal already fired, connect should not connect but call the callback right now. > >> 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 Nice. But that would move our target platform to 2.5. Do we want to do that? I agree, it looks much nicer this way. Dischi -- There are two ways to write error-free programs. Only the third one works.
pgpfAdOBOluDy.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
