From 1da69b139618003c80ab08ef849dc5910cd5c3f6 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 3 Aug 2018 09:41:18 -0400 Subject: [PATCH] Allow daemonizing top level actor; don't require main func --- tractor/_actor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index fe99c73..d530db3 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -624,11 +624,14 @@ async def _start_actor(actor, main, host, port, arbiter_addr, nursery=None): arbiter_addr=arbiter_addr, ) ) - result = await main() - # XXX: If spawned locally, the actor is cancelled when this - # context is complete given that there are no more active - # peer channels connected to it. - actor.cancel_server() + if main is not None: + result = await main() + # XXX: If spawned with a dedicated "main function", + # the actor is cancelled when this context is complete + # given that there are no more active peer channels connected to it. + actor.cancel_server() + + # block on actor to complete # unset module state _state._current_actor = None