transcribe._sleep: make it usable from deallocate()
If we're closing because of an error, we need to sleep through the old error, to be able to wait for the "deallocated" message. This might want to be different: maybe clear the error first, or store the errors in a list and sleep until a second error happens.
This commit is contained in:
parent
4eaf88d7d2
commit
8d0bcf9f82
|
@ -181,13 +181,16 @@ class Wormhole:
|
||||||
return self._signal_error(welcome["error"])
|
return self._signal_error(welcome["error"])
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _sleep(self):
|
def _sleep(self, wake_on_error=True):
|
||||||
if self._error: # don't sleep if the bed's already on fire
|
if wake_on_error and self._error:
|
||||||
|
# don't sleep if the bed's already on fire, unless we're waiting
|
||||||
|
# for the fire department to respond, in which case sure, keep on
|
||||||
|
# sleeping
|
||||||
raise self._error
|
raise self._error
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
self._sleepers.append(d)
|
self._sleepers.append(d)
|
||||||
yield d
|
yield d
|
||||||
if self._error:
|
if wake_on_error and self._error:
|
||||||
raise self._error
|
raise self._error
|
||||||
|
|
||||||
def _wakeup(self):
|
def _wakeup(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user