Add IO sleep to agent forward communications.

Without this, use of agent forwarding causes
high CPU usage on some clients.
(cherry picked from commit 3030589aaa)

Conflicts:
	paramiko/agent.py
This commit is contained in:
Jeff Forcier 2012-01-17 12:10:57 -08:00
parent c903245ed9
commit 3d598a64b4
3 changed files with 9 additions and 1 deletions

View File

@ -103,6 +103,8 @@ from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \ from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED
from common import io_sleep
__all__ = [ 'Transport', __all__ = [ 'Transport',
'SSHClient', 'SSHClient',
'MissingHostKeyPolicy', 'MissingHostKeyPolicy',
@ -136,4 +138,5 @@ __all__ = [ 'Transport',
'AgentKey', 'AgentKey',
'HostKeys', 'HostKeys',
'SSHConfig', 'SSHConfig',
'util' ] 'util',
'io_sleep' ]

View File

@ -34,6 +34,7 @@ from paramiko.ssh_exception import SSHException
from paramiko.message import Message from paramiko.message import Message
from paramiko.pkey import PKey from paramiko.pkey import PKey
from paramiko.channel import Channel from paramiko.channel import Channel
from paramiko.common import io_sleep
SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \ SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \
SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15) SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15)
@ -134,6 +135,7 @@ class AgentProxyThread(threading.Thread):
self._agent._conn.send(data) self._agent._conn.send(data)
else: else:
break break
time.sleep(io_sleep)
class AgentLocalProxy(AgentProxyThread): class AgentLocalProxy(AgentProxyThread):
""" """

View File

@ -124,3 +124,6 @@ INFO = logging.INFO
WARNING = logging.WARNING WARNING = logging.WARNING
ERROR = logging.ERROR ERROR = logging.ERROR
CRITICAL = logging.CRITICAL CRITICAL = logging.CRITICAL
# Common IO/select/etc sleep period, in seconds
io_sleep = 0.01