Commit 1fabf762 by rfkelly0

fix race condition in watch_inotify

parent c56bc5e2
......@@ -47,7 +47,6 @@ class OSFSWatchMixin(WatchableFSMixin):
OSFSWatchMixin.__watch_thread = None
finally:
self.__watch_lock.release()
def add_watcher(self,callback,path="/",events=None,recursive=True):
super_add_watcher = super(OSFSWatchMixin,self).add_watcher
......@@ -203,7 +202,7 @@ class SharedThreadedNotifier(threading.Thread):
def __init__(self):
super(SharedThreadedNotifier,self).__init__()
self.daemon = True
self.running = False
self.running = True
self._pipe_r, self._pipe_w = os.pipe()
self._poller = select.poll()
self._poller.register(self._pipe_r,select.POLLIN)
......@@ -231,7 +230,6 @@ class SharedThreadedNotifier(threading.Thread):
_select_error = select.error
_select_POLLIN = select.POLLIN
# Loop until stopped, dispatching to individual notifiers.
self.running = True
while self.running:
try:
ready_fds = self._poller.poll()
......
......@@ -143,12 +143,18 @@ class TestXAttr_TempFS(unittest.TestCase,FSTestCases,XAttrTestCases):
self.fs = ensure_xattrs(fs)
def tearDown(self):
td = self.fs._temp_dir
try:
td = self.fs._temp_dir
except AttributeError:
td = self.fs.wrapped_fs._temp_dir
self.fs.close()
self.assert_(not os.path.exists(td))
def check(self, p):
td = self.fs._temp_dir
try:
td = self.fs._temp_dir
except AttributeError:
td = self.fs.wrapped_fs._temp_dir
return os.path.exists(os.path.join(td, relpath(p)))
......
......@@ -314,9 +314,15 @@ class WatchableFS(WatchableFSMixin,WrapFS):
raise DirectoryNotEmptyError(path)
else:
for nm in self.listdir(path,dirs_only=True):
self.removedir(pathjoin(path,nm),force=True)
try:
self.removedir(pathjoin(path,nm),force=True)
except ResourceNotFoundError:
pass
for nm in self.listdir(path,files_only=True):
self.remove(pathjoin(path,nm))
try:
self.remove(pathjoin(path,nm))
except ResourceNotFoundError:
pass
super(WatchableFS,self).removedir(path)
self.notify_watchers(REMOVED,path)
if recursive:
......
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