@@ -31,6 +31,7 @@ OPTS_MAP = {
3131 " user" : libssh.SSH_OPTIONS_USER,
3232 " port" : libssh.SSH_OPTIONS_PORT,
3333 " timeout" : libssh.SSH_OPTIONS_TIMEOUT,
34+ " timeout_usec" : libssh.SSH_OPTIONS_TIMEOUT_USEC,
3435 " knownhosts" : libssh.SSH_OPTIONS_KNOWNHOSTS,
3536 " proxycommand" : libssh.SSH_OPTIONS_PROXYCOMMAND,
3637 " key_exchange_algorithms" : libssh.SSH_OPTIONS_KEY_EXCHANGE,
@@ -108,6 +109,7 @@ cdef class Session(object):
108109 self ._hash_py = None
109110 self ._fingerprint_py = None
110111 self ._keytype_py = None
112+ self ._retries = 0
111113 # Due to delayed freeing of channels, some older libssh versions might expect
112114 # the callbacks to be around even after we free the underlying channels so
113115 # we should free them only when we terminate the session.
@@ -175,7 +177,7 @@ cdef class Session(object):
175177 elif key == " port" :
176178 value_uint = value
177179 libssh.ssh_options_set(self ._libssh_session, key_m, & value_uint)
178- elif key == " timeout" :
180+ elif key in { " timeout" , " timeout_usec " } :
179181 value_long = value
180182 libssh.ssh_options_set(self ._libssh_session, key_m, & value_long)
181183 else :
@@ -235,9 +237,17 @@ cdef class Session(object):
235237 file should be validated. It defaults to True
236238 :type host_key_checking: boolean
237239
240+ :param open_session_retries: The number of retries to attempt when libssh
241+ channel function ``ssh_channel_open_session()`` returns ``SSH_AGAIN``. It defaults
242+ to 0, no retries attempted.
243+ :type open_session_retries: integer
244+
238245 :param timeout: The timeout in seconds for the TCP connect
239246 :type timeout: long integer
240247
248+ :param timeout_usec: The timeout in microseconds for the TCP connect
249+ :type timeout_usec: long integer
250+
241251 :param port: The ssh server port to connect to
242252 :type port: integer
243253
@@ -261,6 +271,9 @@ cdef class Session(object):
261271 libssh.ssh_disconnect(self ._libssh_session)
262272 raise
263273
274+ if ' open_session_retries' in kwargs:
275+ self ._retries = kwargs[' open_session_retries' ]
276+
264277 # We need to userauth_none before we can query the available auth types
265278 rc = libssh.ssh_userauth_none(self ._libssh_session, NULL )
266279 if rc == libssh.SSH_AUTH_SUCCESS:
@@ -553,3 +566,6 @@ cdef class Session(object):
553566
554567cdef libssh.ssh_session get_libssh_session(Session session):
555568 return session._libssh_session
569+
570+ cdef int get_session_retries(Session session):
571+ return session._retries
0 commit comments