added notification to cmd_receive plus reactor cleanup
Added a try finally block around verify to ensure notification deferreds are being cleaned out of the reactor
This commit is contained in:
parent
a2ab1863cf
commit
01318d1130
|
@ -75,7 +75,16 @@ class TwistedReceiver:
|
|||
@inlineCallbacks
|
||||
def _go(self, w):
|
||||
yield self._handle_code(w)
|
||||
verifier = yield w.verify()
|
||||
yield w.establish_key()
|
||||
def on_slow_connection():
|
||||
print(u"Key established, waiting for confirmation...",
|
||||
file=self.args.stdout)
|
||||
notify = self._reactor.callLater(1, on_slow_connection)
|
||||
try:
|
||||
verifier = yield w.verify()
|
||||
finally:
|
||||
if not notify.called:
|
||||
notify.cancel()
|
||||
self._show_verifier(verifier)
|
||||
|
||||
want_offer = True
|
||||
|
|
|
@ -85,12 +85,19 @@ class Sender:
|
|||
print(u"Wormhole code is: %s" % code, file=args.stdout)
|
||||
print(u"", file=args.stdout)
|
||||
|
||||
key_established = yield w.establish_key()
|
||||
print(u"Key established, waiting for confirmation...",
|
||||
file=args.stdout)
|
||||
yield w.establish_key()
|
||||
def on_slow_connection():
|
||||
print(u"Key established, waiting for confirmation...",
|
||||
file=args.stdout)
|
||||
notify = self._reactor.callLater(1, on_slow_connection)
|
||||
|
||||
# TODO: don't stall on w.verify() unless they want it
|
||||
verifier_bytes = yield w.verify() # this may raise WrongPasswordError
|
||||
try:
|
||||
verifier_bytes = yield w.verify() # this may raise WrongPasswordError
|
||||
finally:
|
||||
if not notify.called:
|
||||
notify.cancel()
|
||||
|
||||
if args.verify:
|
||||
verifier = bytes_to_hexstr(verifier_bytes)
|
||||
while True:
|
||||
|
|
|
@ -289,7 +289,6 @@ class _Wormhole:
|
|||
returns a Deferred that fires when we've established the shared key.
|
||||
When successful, the Deferred fires with a simple `True`, otherwise
|
||||
it fails.
|
||||
|
||||
"""
|
||||
return self._API_establish_key()
|
||||
|
||||
|
@ -582,7 +581,7 @@ class _Wormhole:
|
|||
|
||||
def _API_establish_key(self):
|
||||
if self._error: return defer.fail(self._error)
|
||||
if not self._key is None:
|
||||
if self._key is not None:
|
||||
return defer.succeed(True)
|
||||
self._key_waiter = defer.Deferred()
|
||||
return self._key_waiter
|
||||
|
|
Loading…
Reference in New Issue
Block a user