summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@twitter.com>2009-07-19 20:53:00 -0700
committerRobey Pointer <robey@twitter.com>2009-07-19 20:53:00 -0700
commitf573017a1d56c0ef9fdb08598bf4a43f40c01952 (patch)
treec7a70bb7d056f1fdc5e560b0f8f61263318ae086
parent62bc0ad79ac882cbef1b2f061e709ab781ccb80c (diff)
patch from evan jones: simplify wait_for_event.
-rw-r--r--paramiko/channel.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py
index f2ad1f51..0798d73b 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -291,10 +291,8 @@ class Channel (object):
@since: 1.2
"""
- while True:
- if self.closed or self.status_event.isSet():
- break
- self.status_event.wait(0.1)
+ self.status_event.wait()
+ assert self.status_event.isSet()
return self.exit_status
def send_exit_status(self, status):
@@ -1070,16 +1068,13 @@ class Channel (object):
self.logger.log(level, "[chan " + self._name + "] " + msg, *args)
def _wait_for_event(self):
- while True:
- self.event.wait(0.1)
- if self.event.isSet():
- return
- if self.closed:
- e = self.transport.get_exception()
- if e is None:
- e = SSHException('Channel closed.')
- raise e
- return
+ self.event.wait()
+ assert self.event.isSet()
+ if self.closed:
+ e = self.transport.get_exception()
+ if e is None:
+ e = SSHException('Channel closed.')
+ raise e
def _set_closed(self):
# you are holding the lock.
@@ -1087,6 +1082,9 @@ class Channel (object):
self.in_buffer.close()
self.in_stderr_buffer.close()
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:
self._pipe.set_forever()