proper daemonize error-handling

This commit is contained in:
meejah 2018-01-31 13:04:17 -07:00
parent 08e0c3b7e2
commit 5d6a76ffee
2 changed files with 7 additions and 10 deletions

View File

@ -154,9 +154,6 @@ class DaemonizeTheRealService(Service, HookMixin):
d.addCallback(created)
d.addErrback(handle_config_error)
d.addBoth(self._call_hook, 'running')
# we've handled error via hook now (otherwise Twisted will
# want to fail some things)
d.addErrback(lambda _: None)
return d
from twisted.internet import reactor

View File

@ -45,16 +45,16 @@ class Util(unittest.TestCase):
self.assertTrue(service is not None)
# @defer.inlineCallbacks
def test_daemonize_no_keygen(self):
tmpdir = self.mktemp()
plug = DaemonizeTahoeNodePlugin('key-generator', tmpdir)
if True:#with patch('twisted.internet.reactor') as r:
with patch('twisted.internet.reactor') as r:
def call(fn, *args, **kw):
fn()
# r.callWhenRunning = call
# r.stop = 'foo'
d = fn()
d.addErrback(lambda _: None) # ignore the error we'll trigger
r.callWhenRunning = call
r.stop = 'foo'
service = plug.makeService(None)
service.parent = Mock()
# we'll raise ValueError because there's no key-generator
@ -65,10 +65,10 @@ class Util(unittest.TestCase):
def done(f):
self.assertIn(
"key-generator support removed",
str(str(f)),#ctx.exception)
str(f),
)
return None
d.addErrback(done)
d.addBoth(done)
return d
def test_daemonize_unknown_nodetype(self):