I am trying to catch this particular exception (and only this exception) in Python 2.7, but I can't seem to find documentation on the exception class. Is there one?
[Errno 10054] An existing connection was forcibly closed by the remote host
My code so far:
try:
# Deleting filename
self.ftp.delete(filename)
return True
except (error_reply, error_perm, error_temp):
return False
except # ?? What goes here for Errno 10054 ??
reconnect()
retry_action()
解决方案
The error type is socket.error, the documentation is here.
Try modiffying your code like this:
import socket
import errno
try:
Deleting filename
self.ftp.delete(filename)
return True
except (error_reply, error_perm, error_temp):
return False
except socket.error as error:
if error.errno == errno.WSAECONNRESET:
reconnect()
retry_action()
else:
raise