Skip to content

Commit 7dc3833

Browse files
committed
Don't raise on EAGAIN during sftp open
1 parent 24ddbf3 commit 7dc3833

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ssh2/sftp.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,18 @@ cdef class SFTP:
184184
:raises: :py:class:`ssh2.exceptions.SFTPHandleError` on errors opening
185185
file.
186186
"""
187-
cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle
187+
cdef c_sftp.LIBSSH2_SFTP_HANDLE *_handle = NULL
188188
cdef bytes b_filename = to_bytes(filename)
189189
cdef char *_filename = b_filename
190+
cdef int rc = c_ssh2.LIBSSH2_ERROR_EAGAIN
191+
190192
with nogil:
191-
_handle = c_sftp.libssh2_sftp_open(
192-
self._sftp, _filename, flags, mode)
193+
while _handle == NULL and rc == c_ssh2.LIBSSH2_ERROR_EAGAIN:
194+
_handle = c_sftp.libssh2_sftp_open(
195+
self._sftp, _filename, flags, mode)
196+
197+
rc = c_ssh2.libssh2_session_last_errno(self._session._session)
198+
193199
if _handle is NULL:
194200
raise SFTPHandleError(
195201
"Could not open file %s - error code %s - %s", filename,

0 commit comments

Comments
 (0)