Commit 66fba24f by rfkelly0

test_remote.DisconnectingFS: only raise RemoteConnectionError from actual FS interface methods

parent 511ce997
...@@ -269,8 +269,14 @@ class ConnectionManagerFS(WrapFS): ...@@ -269,8 +269,14 @@ class ConnectionManagerFS(WrapFS):
self._connection_cond.release() self._connection_cond.release()
def close(self): def close(self):
# Don't close if we haven't created it
try: try:
self.wrapped_fs.close() fs = self.__dict__["wrapped_fs"]
except KeyError:
pass
else:
try:
fs.close()
except (RemoteConnectionError,AttributeError): except (RemoteConnectionError,AttributeError):
pass pass
if self._poll_thread: if self._poll_thread:
......
...@@ -73,10 +73,15 @@ class DisconnectingFS(WrapFS): ...@@ -73,10 +73,15 @@ class DisconnectingFS(WrapFS):
self._connected = True self._connected = True
self.wrapped_fs.close() self.wrapped_fs.close()
def _encode(self,path): def disconnecting_wrapper(func):
"""Method wrapper to raise RemoteConnectionError if not connected."""
@wraps(func)
def wrapper(self,*args,**kwds):
if not self._connected: if not self._connected:
raise RemoteConnectionError("") raise RemoteConnectionError("")
return path return func(self,*args,**kwds)
return wrapper
DisconnectingFS = wrap_fs_methods(disconnecting_wrapper)(DisconnectingFS)
class DisconnectRecoveryFS(WrapFS): class DisconnectRecoveryFS(WrapFS):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment