-
-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFTPStorage: keep trying to connect when timeout (in a loop) #1064
Comments
I came across the same issue and was able to work around it by using @SorianoMarmol's approach. |
Sorry, I don't understand. What do you mean by |
i mean, instead of raise an exception (timeout or paramiko.AuthenticationException) _connect are returning none I think the expected behavior should be to throw the exception (since it can't connect due to timeout). In my workaround I throw the exception to handle it. Without it, it tries to always connect, in a loop, when saving the file maybe it can be easily replicated with very little timeout thanks |
Is the problem that Assuming I have access to an SFTP server and can set the timeout very low, can you give me example code? |
eliminated the part of "None" since it could have been a confusion and with the example the problem is illustrated
could be , please, check next comment
is a field of type filefield with
thanks for your answer, I can try some more debugging or try whatever if needed |
A bit of debugging ( all calls have the "exists" part in common ) first .sftp call
second
third
q
|
@SorianoMarmol can you try with this patch diff --git a/storages/backends/sftpstorage.py b/storages/backends/sftpstorage.py
index 529daf2..643685c 100644
--- a/storages/backends/sftpstorage.py
+++ b/storages/backends/sftpstorage.py
@@ -150,7 +150,7 @@ class SFTPStorage(BaseStorage):
try:
self.sftp.stat(self._remote_path(name))
return True
- except OSError:
+ except FileNotFoundError:
return False
def _isdir_attr(self, item): |
@SorianoMarmol can you also confirm that |
The patch does work, I will merge the fix shortly. |
thanks a lot! |
I was implementing saving a file in SFTP and, when testing time out, it was never launched.
I have debugged and it goes into a loop trying to connect.
Specifically:
the exception thrown is socket "timeout" (
from socket import timeout
)I may not have done something correctly, but I have done this workaround (maybe it helps someone, or to illustrate the problem)
thanks
The text was updated successfully, but these errors were encountered: