Skip to content

Commit

Permalink
patch from evan jones: simplify wait_for_event.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robey Pointer committed Jul 20, 2009
1 parent 62bc0ad commit f573017
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions paramiko/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ def recv_exit_status(self):
@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):
Expand Down Expand Up @@ -1070,23 +1068,23 @@ def _log(self, level, msg, *args):
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.
self.closed = True
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()

Expand Down

0 comments on commit f573017

Please sign in to comment.