mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 18:06:46 +00:00
That was all nonsense. Throw it out.
This commit is contained in:
parent
e55ee7d044
commit
19f06809e2
@ -81,49 +81,43 @@ def eliot_friendly_generator_function(original):
|
|||||||
# decorated generator is running, it might be the stack for that
|
# decorated generator is running, it might be the stack for that
|
||||||
# generator. Not our business.
|
# generator. Not our business.
|
||||||
_the_generator_context.init_stack(gen)
|
_the_generator_context.init_stack(gen)
|
||||||
try:
|
while True:
|
||||||
while True:
|
try:
|
||||||
try:
|
# Whichever way we invoke the generator, we will do it
|
||||||
# Whichever way we invoke the generator, we will do it
|
# with the Eliot action context stack we've saved for it.
|
||||||
# with the Eliot action context stack we've saved for it.
|
# Then the context manager will re-save it and restore the
|
||||||
# Then the context manager will re-save it and restore the
|
# "outside" stack for us.
|
||||||
# "outside" stack for us.
|
with _the_generator_context.context(gen):
|
||||||
with _the_generator_context.context(gen):
|
if ok:
|
||||||
if ok:
|
value_out = gen.send(value_in)
|
||||||
value_out = gen.send(value_in)
|
|
||||||
else:
|
|
||||||
value_out = gen.throw(*value_in)
|
|
||||||
# We have obtained a value from the generator. In
|
|
||||||
# giving it to us, it has given up control. Note this
|
|
||||||
# fact here. Importantly, this is within the
|
|
||||||
# generator's action context so that we get a good
|
|
||||||
# indication of where the yield occurred.
|
|
||||||
#
|
|
||||||
# This might be too noisy, consider dropping it or
|
|
||||||
# making it optional.
|
|
||||||
Message.log(message_type=u"yielded")
|
|
||||||
except StopIteration:
|
|
||||||
# When the generator raises this, it is signaling
|
|
||||||
# completion. Leave the loop.
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
# Pass the generator's result along to whoever is
|
|
||||||
# driving. Capture the result as the next value to
|
|
||||||
# send inward.
|
|
||||||
value_in = yield value_out
|
|
||||||
except:
|
|
||||||
# Or capture the exception if that's the flavor of the
|
|
||||||
# next value.
|
|
||||||
ok = False
|
|
||||||
value_in = exc_info()
|
|
||||||
else:
|
else:
|
||||||
ok = True
|
value_out = gen.throw(*value_in)
|
||||||
except GeneratorExit:
|
# We have obtained a value from the generator. In
|
||||||
# Is this the right scope for handling this exception? Something
|
# giving it to us, it has given up control. Note this
|
||||||
# to check on. Anyhow, if we get it, propagate it inward so the
|
# fact here. Importantly, this is within the
|
||||||
# generator we're driving knows we're done with it.
|
# generator's action context so that we get a good
|
||||||
gen.close()
|
# indication of where the yield occurred.
|
||||||
|
#
|
||||||
|
# This might be too noisy, consider dropping it or
|
||||||
|
# making it optional.
|
||||||
|
Message.log(message_type=u"yielded")
|
||||||
|
except StopIteration:
|
||||||
|
# When the generator raises this, it is signaling
|
||||||
|
# completion. Leave the loop.
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
# Pass the generator's result along to whoever is
|
||||||
|
# driving. Capture the result as the next value to
|
||||||
|
# send inward.
|
||||||
|
value_in = yield value_out
|
||||||
|
except:
|
||||||
|
# Or capture the exception if that's the flavor of the
|
||||||
|
# next value.
|
||||||
|
ok = False
|
||||||
|
value_in = exc_info()
|
||||||
|
else:
|
||||||
|
ok = True
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user