Commit 62b99816 by rfkelly0

some performance tweaks for ConnectionManagerFS

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