make sure shutdown failures go somewhere good

This commit is contained in:
Jean-Paul Calderone 2019-02-20 12:41:33 -05:00
parent ebd017cf2b
commit 7a9f52d2e5

View File

@ -22,6 +22,7 @@ from eliot import (
Field,
ActionType,
MessageType,
write_failure,
)
from eliot.twisted import DeferredContext
@ -406,10 +407,7 @@ class MagicFolder(service.MultiService):
def stopService(self):
with MAGIC_FOLDER_STOP(nickname=self.name).context():
d = DeferredContext(defer.gatherResults([
self.uploader.stop(),
self.downloader.stop(),
]))
d = DeferredContext(self._finish())
d.addBoth(
lambda ign: service.MultiService.stopService(self)
)
@ -422,6 +420,14 @@ class MagicFolder(service.MultiService):
self.uploader.start_uploading() # synchronous, returns None
return self.downloader.start_downloading()
def _finish(self):
d0 = self.downloader.stop()
d1 = self.uploader.stop()
return defer.DeferredList([
DeferredContext(d0).addErrback(write_failure).result,
DeferredContext(d1).addErrback(write_failure).result,
])
_NICKNAME = Field.for_types(
u"nickname",