mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 16:36:20 +00:00
try not creating a duplicate Observer
This commit is contained in:
parent
679b9a93c1
commit
725c85b2f4
@ -1144,8 +1144,14 @@ class Uploader(QueueMixin):
|
||||
| self._inotify.IN_ONLYDIR
|
||||
| IN_EXCL_UNLINK
|
||||
)
|
||||
self._notifier.watch(self._local_filepath, mask=self.mask, callbacks=[self._notify],
|
||||
recursive=True)
|
||||
|
||||
def _add_watch(self):
|
||||
self._notifier.watch(
|
||||
self._local_filepath,
|
||||
mask=self.mask,
|
||||
callbacks=[self._notify],
|
||||
recursive=True,
|
||||
)
|
||||
|
||||
def start_monitoring(self):
|
||||
action = START_MONITORING(**self._log_fields)
|
||||
@ -1153,6 +1159,7 @@ class Uploader(QueueMixin):
|
||||
d = DeferredContext(defer.succeed(None))
|
||||
|
||||
d.addCallback(lambda ign: self._notifier.startReading())
|
||||
d.addCallback(lambda ign: self._add_watch())
|
||||
d.addCallback(lambda ign: self._count('dirs_monitored'))
|
||||
d.addBoth(self._call_hook, 'started')
|
||||
return d.addActionFinish()
|
||||
|
@ -161,7 +161,6 @@ class INotify(PollMixin):
|
||||
def __init__(self):
|
||||
self._pending_delay = 1.0
|
||||
self.recursive_includes_new_subdirectories = False
|
||||
self._observer = Observer(timeout=self._pending_delay)
|
||||
self._callbacks = {}
|
||||
self._watches = {}
|
||||
self._state = NOT_STARTED
|
||||
@ -170,7 +169,6 @@ class INotify(PollMixin):
|
||||
Message.log(message_type=u"watchdog:inotify:set-pending-delay", delay=delay)
|
||||
assert self._state != STARTED
|
||||
self._pending_delay = delay
|
||||
self._observer = Observer(timeout=self._pending_delay)
|
||||
|
||||
def startReading(self):
|
||||
with start_action(action_type=u"watchdog:inotify:start-reading"):
|
||||
@ -179,6 +177,7 @@ class INotify(PollMixin):
|
||||
# XXX twisted.internet.inotify doesn't require watches to
|
||||
# be set before startReading is called.
|
||||
# _assert(len(self._callbacks) != 0, "no watch set")
|
||||
self._observer = Observer(timeout=self._pending_delay)
|
||||
self._observer.start()
|
||||
self._state = STARTED
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user