mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-01 18:56:41 +00:00
Merge pr337 from meejah:2218.fix-shutdown.0
closes tahoe-lafs/tahoe-lafs#337
This commit is contained in:
commit
ff82112b89
@ -6,6 +6,7 @@ from datetime import datetime
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from twisted.internet import defer, reactor, task
|
from twisted.internet import defer, reactor, task
|
||||||
|
from twisted.internet.error import AlreadyCancelled
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
from twisted.python import runtime
|
from twisted.python import runtime
|
||||||
from twisted.python import log as twlog
|
from twisted.python import log as twlog
|
||||||
@ -101,6 +102,9 @@ class MagicFolder(service.MultiService):
|
|||||||
service.MultiService.startService(self)
|
service.MultiService.startService(self)
|
||||||
return self.uploader.start_monitoring()
|
return self.uploader.start_monitoring()
|
||||||
|
|
||||||
|
def stopService(self):
|
||||||
|
return self.finish()
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
"""ready is used to signal us to start
|
"""ready is used to signal us to start
|
||||||
processing the upload and download items...
|
processing the upload and download items...
|
||||||
@ -347,6 +351,7 @@ class Uploader(QueueMixin):
|
|||||||
self._pending = set() # of unicode relpaths
|
self._pending = set() # of unicode relpaths
|
||||||
|
|
||||||
self._periodic_full_scan_duration = 10 * 60 # perform a full scan every 10 minutes
|
self._periodic_full_scan_duration = 10 * 60 # perform a full scan every 10 minutes
|
||||||
|
self._periodic_callid = None
|
||||||
|
|
||||||
if hasattr(self._notifier, 'set_pending_delay'):
|
if hasattr(self._notifier, 'set_pending_delay'):
|
||||||
self._notifier.set_pending_delay(pending_delay)
|
self._notifier.set_pending_delay(pending_delay)
|
||||||
@ -377,7 +382,12 @@ class Uploader(QueueMixin):
|
|||||||
self._stopped = True
|
self._stopped = True
|
||||||
self._notifier.stopReading()
|
self._notifier.stopReading()
|
||||||
self._count('dirs_monitored', -1)
|
self._count('dirs_monitored', -1)
|
||||||
self.periodic_callid.cancel()
|
if self._periodic_callid:
|
||||||
|
try:
|
||||||
|
self._periodic_callid.cancel()
|
||||||
|
except AlreadyCancelled:
|
||||||
|
pass
|
||||||
|
|
||||||
if hasattr(self._notifier, 'wait_until_stopped'):
|
if hasattr(self._notifier, 'wait_until_stopped'):
|
||||||
d = self._notifier.wait_until_stopped()
|
d = self._notifier.wait_until_stopped()
|
||||||
else:
|
else:
|
||||||
@ -402,7 +412,7 @@ class Uploader(QueueMixin):
|
|||||||
return self._begin_processing(None)
|
return self._begin_processing(None)
|
||||||
|
|
||||||
def _full_scan(self):
|
def _full_scan(self):
|
||||||
self.periodic_callid = self._clock.callLater(self._periodic_full_scan_duration, self._full_scan)
|
self._periodic_callid = self._clock.callLater(self._periodic_full_scan_duration, self._full_scan)
|
||||||
self._log("FULL SCAN")
|
self._log("FULL SCAN")
|
||||||
self._log("_pending %r" % (self._pending))
|
self._log("_pending %r" % (self._pending))
|
||||||
self._scan(u"")
|
self._scan(u"")
|
||||||
|
Loading…
Reference in New Issue
Block a user