Commit 396d635e by rfkelly0

more adjustments for new "close" method

parent d74ba1ec
...@@ -15,7 +15,7 @@ implementations of this interface such as: ...@@ -15,7 +15,7 @@ implementations of this interface such as:
""" """
__version__ = "0.2.0a5" __version__ = "0.2.0a6"
__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
......
...@@ -701,6 +701,7 @@ class SubFS(FS): ...@@ -701,6 +701,7 @@ class SubFS(FS):
def __init__(self, parent, sub_dir): def __init__(self, parent, sub_dir):
self.parent = parent self.parent = parent
self.sub_dir = abspath(normpath(sub_dir)) self.sub_dir = abspath(normpath(sub_dir))
FS.__init__(self,thread_synchronize=False)
def __str__(self): def __str__(self):
return "<SubFS: %s in %s>" % (self.sub_dir, self.parent) return "<SubFS: %s in %s>" % (self.sub_dir, self.parent)
......
...@@ -106,6 +106,7 @@ class RPCFS(FS): ...@@ -106,6 +106,7 @@ class RPCFS(FS):
self.uri = uri self.uri = uri
self._transport = transport self._transport = transport
self.proxy = self._make_proxy() self.proxy = self._make_proxy()
FS.__init__(self,thread_synchronize=False)
def _make_proxy(self): def _make_proxy(self):
kwds = dict(allow_none=True) kwds = dict(allow_none=True)
......
...@@ -46,13 +46,13 @@ class DisconnectingFS(WrapFS): ...@@ -46,13 +46,13 @@ class DisconnectingFS(WrapFS):
def __init__(self,fs=None): def __init__(self,fs=None):
if fs is None: if fs is None:
fs = TempFS() fs = TempFS()
super(DisconnectingFS,self).__init__(fs) self._connected = True
self._connected = random.choice([True,False])
if not self._connected:
raise RemoteConnectionError("")
self._continue = True self._continue = True
self._bounce_thread = threading.Thread(target=self._bounce) self._bounce_thread = threading.Thread(target=self._bounce)
self._bounce_thread.start() self._bounce_thread.start()
super(DisconnectingFS,self).__init__(fs)
if random.choice([True,False]):
raise RemoteConnectionError("")
def __getstate__(self): def __getstate__(self):
state = super(DisconnectingFS,self).__getstate__() state = super(DisconnectingFS,self).__getstate__()
...@@ -70,13 +70,17 @@ class DisconnectingFS(WrapFS): ...@@ -70,13 +70,17 @@ class DisconnectingFS(WrapFS):
self._connected = not self._connected self._connected = not self._connected
def close(self): def close(self):
self._continue = False if not self.closed:
self._bounce_thread.join() self._continue = False
self._connected = True self._bounce_thread.join()
self.wrapped_fs.close() self._connected = True
self.wrapped_fs.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:
......
...@@ -27,11 +27,11 @@ class TestS3FS(unittest.TestCase,FSTestCases,ThreadingTestCases): ...@@ -27,11 +27,11 @@ class TestS3FS(unittest.TestCase,FSTestCases,ThreadingTestCases):
self.fs._s3bukt.delete_key(k) self.fs._s3bukt.delete_key(k)
def test_concurrent_copydir(self): def test_concurrent_copydir(self):
# makdir() on S3FS is currently not atomic # makedir() on S3FS is currently not atomic
pass pass
def test_makedir_winner(self): def test_makedir_winner(self):
# makdir() on S3FS is currently not atomic # makedir() on S3FS is currently not atomic
pass pass
def test_multiple_overwrite(self): def test_multiple_overwrite(self):
......
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