forked from goodboy/tractor
Always call `Actor.cancel()` at end of root's main task
It's simpler and the only real logical difference is logging messages. This should also give us an overall consistent tear down sequence.drop_warn
parent
676cdafa8f
commit
3b8684f655
|
@ -1083,19 +1083,12 @@ async def _start_actor(
|
||||||
try:
|
try:
|
||||||
result = await main()
|
result = await main()
|
||||||
except (Exception, trio.MultiError) as err:
|
except (Exception, trio.MultiError) as err:
|
||||||
try:
|
log.exception("Actor crashed:")
|
||||||
log.exception("Actor crashed:")
|
await _debug._maybe_enter_pm(err)
|
||||||
await _debug._maybe_enter_pm(err)
|
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
finally:
|
await actor.cancel()
|
||||||
await actor.cancel()
|
|
||||||
|
|
||||||
# XXX: the actor is cancelled when this context is complete
|
|
||||||
# given that there are no more active peer channels connected
|
|
||||||
actor.cancel_server()
|
|
||||||
actor._service_n.cancel_scope.cancel()
|
|
||||||
|
|
||||||
# unset module state
|
# unset module state
|
||||||
_state._current_actor = None
|
_state._current_actor = None
|
||||||
|
|
Loading…
Reference in New Issue