patch from evan jones: simplify wait_for_event.
This commit is contained in:
parent
62bc0ad79a
commit
f573017a1d
|
@ -291,10 +291,8 @@ class Channel (object):
|
||||||
|
|
||||||
@since: 1.2
|
@since: 1.2
|
||||||
"""
|
"""
|
||||||
while True:
|
self.status_event.wait()
|
||||||
if self.closed or self.status_event.isSet():
|
assert self.status_event.isSet()
|
||||||
break
|
|
||||||
self.status_event.wait(0.1)
|
|
||||||
return self.exit_status
|
return self.exit_status
|
||||||
|
|
||||||
def send_exit_status(self, status):
|
def send_exit_status(self, status):
|
||||||
|
@ -1070,16 +1068,13 @@ class Channel (object):
|
||||||
self.logger.log(level, "[chan " + self._name + "] " + msg, *args)
|
self.logger.log(level, "[chan " + self._name + "] " + msg, *args)
|
||||||
|
|
||||||
def _wait_for_event(self):
|
def _wait_for_event(self):
|
||||||
while True:
|
self.event.wait()
|
||||||
self.event.wait(0.1)
|
assert self.event.isSet()
|
||||||
if self.event.isSet():
|
if self.closed:
|
||||||
return
|
e = self.transport.get_exception()
|
||||||
if self.closed:
|
if e is None:
|
||||||
e = self.transport.get_exception()
|
e = SSHException('Channel closed.')
|
||||||
if e is None:
|
raise e
|
||||||
e = SSHException('Channel closed.')
|
|
||||||
raise e
|
|
||||||
return
|
|
||||||
|
|
||||||
def _set_closed(self):
|
def _set_closed(self):
|
||||||
# you are holding the lock.
|
# you are holding the lock.
|
||||||
|
@ -1087,6 +1082,9 @@ class Channel (object):
|
||||||
self.in_buffer.close()
|
self.in_buffer.close()
|
||||||
self.in_stderr_buffer.close()
|
self.in_stderr_buffer.close()
|
||||||
self.out_buffer_cv.notifyAll()
|
self.out_buffer_cv.notifyAll()
|
||||||
|
# Notify any waiters that we are closed
|
||||||
|
self.event.set()
|
||||||
|
self.status_event.set()
|
||||||
if self._pipe is not None:
|
if self._pipe is not None:
|
||||||
self._pipe.set_forever()
|
self._pipe.set_forever()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue