Commit 62b99816 by rfkelly0

some performance tweaks for ConnectionManagerFS

parent b5eefe94
...@@ -15,7 +15,7 @@ implementations of this interface such as: ...@@ -15,7 +15,7 @@ implementations of this interface such as:
""" """
__version__ = "0.2.0a8" __version__ = "0.2.0a9"
__author__ = "Will McGugan (will@willmcgugan.com)" __author__ = "Will McGugan (will@willmcgugan.com)"
# 'base' imports * from 'path' and 'errors', so their # 'base' imports * from 'path' and 'errors', so their
......
...@@ -231,6 +231,9 @@ class ConnectionManagerFS(WrapFS): ...@@ -231,6 +231,9 @@ class ConnectionManagerFS(WrapFS):
finally: finally:
self._connection_cond.release() self._connection_cond.release()
def setcontents(self,path,data):
self.wrapped_fs.setcontents(path,data)
def __getstate__(self): def __getstate__(self):
state = super(ConnectionManagerFS,self).__getstate__() state = super(ConnectionManagerFS,self).__getstate__()
del state["_connection_cond"] del state["_connection_cond"]
......
...@@ -597,6 +597,7 @@ class ThreadingTestCases: ...@@ -597,6 +597,7 @@ class ThreadingTestCases:
if self.fs.exists(subdir): if self.fs.exists(subdir):
self.fs.removedir(subdir,force=True) self.fs.removedir(subdir,force=True)
self.assertFalse(self.fs.isdir(subdir)) self.assertFalse(self.fs.isdir(subdir))
self.assertTrue(self.fs.isdir("/"))
self.fs.makedir(subdir) self.fs.makedir(subdir)
self._yield() self._yield()
getattr(this,meth)() getattr(this,meth)()
...@@ -637,7 +638,8 @@ class ThreadingTestCases: ...@@ -637,7 +638,8 @@ class ThreadingTestCases:
# One thread should succeed, two should error # One thread should succeed, two should error
errors = [] errors = []
self._runThreads(makedir,makedir,makedir) self._runThreads(makedir,makedir,makedir)
self.assertEquals(len(errors),2) if len(errors) != 2:
raise AssertionError(errors)
self.fs.removedir("testdir") self.fs.removedir("testdir")
# All threads should succeed # All threads should succeed
errors = [] errors = []
......
...@@ -74,20 +74,17 @@ class DisconnectingFS(WrapFS): ...@@ -74,20 +74,17 @@ class DisconnectingFS(WrapFS):
self._continue = False self._continue = False
self._bounce_thread.join() self._bounce_thread.join()
self._connected = True self._connected = True
self.wrapped_fs.close()
super(DisconnectingFS,self).close() super(DisconnectingFS,self).close()
def disconnecting_wrapper(func): def disconnecting_wrapper(func):
"""Method wrapper to raise RemoteConnectionError if not connected.""" """Method wrapper to raise RemoteConnectionError if not connected."""
if func.__name__ == "close":
return func
@wraps(func) @wraps(func)
def wrapper(self,*args,**kwds): def wrapper(self,*args,**kwds):
if not self._connected: if not self._connected:
raise RemoteConnectionError("") raise RemoteConnectionError("")
return func(self,*args,**kwds) return func(self,*args,**kwds)
return wrapper return wrapper
DisconnectingFS = wrap_fs_methods(disconnecting_wrapper)(DisconnectingFS) DisconnectingFS = wrap_fs_methods(disconnecting_wrapper,DisconnectingFS,exclude=["close"])
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