[Twisted-Python] Sequential use of asynchronous calls
Ben Artin
ben at artins.org
Sat May 26 17:53:57 EDT 2007
> In my implementation the decorator has a check whether the thing it is
> decorating is really a generator. Without this check, you will get an
> exception only when you start using the decorated function. I think
> it is
> usually better to detect errors at an early stage. However, the
> check uses
> compiler.consts.CO_GENERATOR, which is not documented in the Python
> Library
> Reference, so using it might be risky.
If the argument to the decorator is not a generator (i.e., it's a
regular function), then you should just treat is as a generator that
immediately returned. For example,
@sequential
def foo():
yield retval
should just behave the same as
@sequential
def foo():
return retval
I can't think of any case where passing a non-generator into
@sequential is intended to mean anything other than this.
--
<http://artins.org/ben>
"And when I have understanding of computers, I shall be
the supreme being!" -- Evil, "Time Bandits"
More information about the Twisted-Python
mailing list