Commit 66fba24f by rfkelly0

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

parent 511ce997
...@@ -269,15 +269,21 @@ class ConnectionManagerFS(WrapFS): ...@@ -269,15 +269,21 @@ 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 (RemoteConnectionError,AttributeError): except KeyError:
pass pass
if self._poll_thread: else:
self.connected = True try:
self._poll_sleeper.set() fs.close()
self._poll_thread.join() except (RemoteConnectionError,AttributeError):
self._poll_thread = None pass
if self._poll_thread:
self.connected = True
self._poll_sleeper.set()
self._poll_thread.join()
self._poll_thread = None
def _ConnectionManagerFS_method_wrapper(func): def _ConnectionManagerFS_method_wrapper(func):
"""Method wrapper for ConnectionManagerFS. """Method wrapper for ConnectionManagerFS.
......
...@@ -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