mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 11:50:21 +00:00
properly cancel pending-call things in windows inotify
This commit is contained in:
parent
fce5b789dc
commit
db6717951f
@ -204,6 +204,7 @@ class INotify(PollMixin):
|
|||||||
self._path = None
|
self._path = None
|
||||||
self._pending = set()
|
self._pending = set()
|
||||||
self._pending_delay = 1.0
|
self._pending_delay = 1.0
|
||||||
|
self._pending_call = None
|
||||||
self.recursive_includes_new_subdirectories = True
|
self.recursive_includes_new_subdirectories = True
|
||||||
|
|
||||||
def set_pending_delay(self, delay):
|
def set_pending_delay(self, delay):
|
||||||
@ -217,6 +218,9 @@ class INotify(PollMixin):
|
|||||||
# FIXME race conditions
|
# FIXME race conditions
|
||||||
if self._state != STOPPED:
|
if self._state != STOPPED:
|
||||||
self._state = STOPPING
|
self._state = STOPPING
|
||||||
|
if self._pending_call:
|
||||||
|
self._pending_call.cancel()
|
||||||
|
self._pending_call = None
|
||||||
|
|
||||||
def wait_until_stopped(self):
|
def wait_until_stopped(self):
|
||||||
try:
|
try:
|
||||||
@ -268,10 +272,10 @@ class INotify(PollMixin):
|
|||||||
|
|
||||||
if self._check_stop(): return
|
if self._check_stop(): return
|
||||||
for info in fni:
|
for info in fni:
|
||||||
print info
|
# print info
|
||||||
path = self._path.preauthChild(info.filename) # FilePath with Unicode path
|
path = self._path.preauthChild(info.filename) # FilePath with Unicode path
|
||||||
if info.action == FILE_ACTION_MODIFIED and path.isdir():
|
if info.action == FILE_ACTION_MODIFIED and path.isdir():
|
||||||
print "Filtering out %r" % (info,)
|
# print "Filtering out %r" % (info,)
|
||||||
continue
|
continue
|
||||||
#mask = _action_to_inotify_mask.get(info.action, IN_CHANGED)
|
#mask = _action_to_inotify_mask.get(info.action, IN_CHANGED)
|
||||||
|
|
||||||
@ -279,13 +283,16 @@ class INotify(PollMixin):
|
|||||||
if path not in self._pending:
|
if path not in self._pending:
|
||||||
self._pending.add(path)
|
self._pending.add(path)
|
||||||
def _do_callbacks():
|
def _do_callbacks():
|
||||||
|
self._pending_call = None
|
||||||
self._pending.remove(path)
|
self._pending.remove(path)
|
||||||
|
if self._callbacks:
|
||||||
for cb in self._callbacks:
|
for cb in self._callbacks:
|
||||||
try:
|
try:
|
||||||
cb(None, path, IN_CHANGED)
|
cb(None, path, IN_CHANGED)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.err(e)
|
log.err(e)
|
||||||
reactor.callLater(self._pending_delay, _do_callbacks)
|
if self._pending_call is None and not self._state in [STOPPING, STOPPED]:
|
||||||
|
self._pending_call = reactor.callLater(self._pending_delay, _do_callbacks)
|
||||||
reactor.callFromThread(_maybe_notify, path)
|
reactor.callFromThread(_maybe_notify, path)
|
||||||
if self._check_stop(): return
|
if self._check_stop(): return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -300,5 +307,8 @@ class INotify(PollMixin):
|
|||||||
self._hDirectory = None
|
self._hDirectory = None
|
||||||
CloseHandle(hDirectory)
|
CloseHandle(hDirectory)
|
||||||
self._state = STOPPED
|
self._state = STOPPED
|
||||||
|
if self._pending_call:
|
||||||
|
self._pending_call.cancel()
|
||||||
|
self._pending_call = None
|
||||||
|
|
||||||
return self._state == STOPPED
|
return self._state == STOPPED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user