Commit e91c3e81 by rfkelly0

fix some corner cases in osfs/watch_win32.py

parent d7759718
......@@ -15,7 +15,7 @@ implementations of this interface such as:
"""
__version__ = "0.3.0"
__version__ = "0.4.0a1"
__author__ = "Will McGugan (will@willmcgugan.com)"
# 'base' imports * from 'path' and 'errors', so their
......
......@@ -424,6 +424,7 @@ class FS(object):
"""
raise UnsupportedError("rename resource")
@convert_os_errors
def settimes(self, path, accessed_time=None, modified_time=None):
"""Set the accessed time and modified time of a file
......
......@@ -233,6 +233,8 @@ def convert_os_errors(func):
raise StorageSpaceError(opname,details=e),None,tb
if e.errno == errno.EPERM:
raise PermissionDeniedError(opname,details=e),None,tb
if e.errno == errno.ENOSYS:
raise UnsupportedError(opname,details=e),None,tb
if e.errno == errno.EACCES:
if sys.platform == "win32":
if e.args[0] and e.args[0] == 32:
......
"""
fs.osfs.watch_win32
=============
===================
Change watcher support for OSFS, using ReadDirectoryChangesW on win32.
......@@ -359,7 +359,11 @@ class WatchThread(threading.Thread):
traceback.print_exc()
else:
if iocpkey.value > 1:
try:
w = self.watched_directories[iocpkey.value]
except KeyError:
pass
else:
w.complete(nbytes.value)
w.post()
elif not self.closed:
......@@ -405,11 +409,13 @@ class OSFSWatchMixin(WatchableFSMixin):
try:
path = self.unsyspath(path)
except ValueError:
raise
pass
else:
if event_class in (MOVED_SRC,MOVED_DST) and args and args[0]:
args = (self.unsyspath(args[0]),) + args[1:]
event = event_class(self,path,*args,**kwds)
w.handle_event(event)
w._watch_obj = wt.add_watcher(handle_event,syspath,w.events,w.recursive)
w._watch_objs = wt.add_watcher(handle_event,syspath,w.events,w.recursive)
return w
@convert_os_errors
......@@ -420,7 +426,8 @@ class OSFSWatchMixin(WatchableFSMixin):
else:
watchers = self._find_watchers(watcher_or_callback)
for watcher in watchers:
wt.del_watcher(watcher._watch_obj)
for wobj in watcher._watch_objs:
wt.del_watcher(wobj)
super(OSFSWatchMixin,self).del_watcher(watcher)
if not wt.watched_directories:
self.__shutdown_watch_thread()
......@@ -451,6 +458,8 @@ class OSFSWatchMixin(WatchableFSMixin):
OSFSWatchMixin.__watch_thread.close()
except EnvironmentError:
pass
else:
OSFSWatchMixin.__watch_thread.join()
OSFSWatchMixin.__watch_thread = None
finally:
self.__watch_lock.release()
......
......@@ -47,6 +47,7 @@ class TempFS(OSFS):
Note that once this method has been called, the FS object may
no longer be used.
"""
super(TempFS,self).close()
# Depending on how resources are freed by the OS, there could
# be some transient errors when freeing a TempFS soon after it
# was used. If they occur, do a small sleep and try again.
......
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