Speed up MagicFolder service shutdown

Also work-around a tricky, mysterious failure in the test suite by explicitly
flushing the eventual call queue.  I don't understand where the call that is
landing there comes from or why some other part of the code isn't properly
waiting on it.
This commit is contained in:
Jean-Paul Calderone 2019-01-30 15:55:37 -05:00
parent 644fd04d08
commit 89bb68254b
2 changed files with 9 additions and 0 deletions

View File

@ -712,6 +712,8 @@ class Uploader(QueueMixin):
d = self._notifier.wait_until_stopped()
else:
d = defer.succeed(None)
# Speed up shutdown
self._processing.cancel()
# wait for processing loop to actually exit
d.addCallback(lambda ign: self._processing)
return d
@ -1198,6 +1200,10 @@ class Downloader(QueueMixin, WriteFileMixin):
def stop(self):
self._log("stop")
self._stopped = True
# Speed up shutdown
self._processing.cancel()
d = defer.succeed(None)
# wait for processing loop to actually exit
d.addCallback(lambda ign: self._processing)

View File

@ -1448,6 +1448,9 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall
self.local_dir = os.path.join(self.basedir, u"local_dir")
self.mkdir_nonascii(self.local_dir)
from foolscap.eventual import flushEventualQueue
self.addCleanup(flushEventualQueue)
d = self.create_invite_join_magic_folder(self.alice_nickname, self.local_dir)
d.addCallback(self._restart_client)
# note: _restart_client ultimately sets self.magicfolder to not-None