From 212276af1378fa84811ac5c3504ffcebe1ee58a1 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 17 Nov 2011 15:18:35 -0800 Subject: [PATCH] Port poll-using code to use select() instead. (cherry picked from commit eb49bf4870b8ba099452fac7640878a5fc24d14c) --- paramiko/agent.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/paramiko/agent.py b/paramiko/agent.py index 4b562f7..3405a3d 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)