diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2011-11-17 15:18:35 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2012-09-23 15:55:46 -0700 |
commit | 212276af1378fa84811ac5c3504ffcebe1ee58a1 (patch) | |
tree | d901d139a480bf1f0b6ac579b10836c5d94c17a0 | |
parent | c46fddeb16ec9afff236c0cca2a3b509d811d713 (diff) |
Port poll-using code to use select() instead.
(cherry picked from commit eb49bf4870b8ba099452fac7640878a5fc24d14c)
-rw-r--r-- | paramiko/agent.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/paramiko/agent.py b/paramiko/agent.py index 4b562f78..3405a3de 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -27,8 +27,8 @@ import sys import threading import tempfile import stat -import select import fcntl +from select import select from paramiko.ssh_exception import SSHException from paramiko.message import Message @@ -117,22 +117,18 @@ class AgentProxyThread(threading.Thread): raise def _communicate(self): - p = select.poll() oldflags = fcntl.fcntl(self.__inr, fcntl.F_GETFL) fcntl.fcntl(self.__inr, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) - p.register(self._agent._conn, select.POLLIN) - p.register(self.__inr, select.POLLIN) while not self._exit: - c = p.poll(500) - for cc in c: - fd, event = cc - if self._agent._conn.fileno() == fd: + events = select([self._agent._conn, self.__inr], [], [], 0.5) + for fd in events[0]: + if self._agent._conn == fd: data = self._agent._conn.recv(512) if len(data) != 0: self.__inr.send(data) else: break - elif self.__inr.fileno() == fd: + elif self.__inr == fd: data = self.__inr.recv(512) if len(data) != 0: self._agent._conn.send(data) |