forked from goodboy/tractor
1
0
Fork 0

Propagate `trio.MultiError`s up the actor tree

`trio.MultiError` isn't an `Exception` (derived instead from
`BaseException`) so we have to specially catch it in the task
invocation machinery and ship it upwards (like regular errors)
since nurseries running in sub-actors can raise them.
more_thorough_super_tests
Tyler Goodlet 2019-10-28 00:47:06 -04:00
parent d406383cd3
commit 95e8f3d306
1 changed files with 5 additions and 4 deletions

View File

@ -118,7 +118,7 @@ async def _invoke(
with cancel_scope as cs:
task_status.started(cs)
await chan.send({'return': await coro, 'cid': cid})
except Exception as err:
except (Exception, trio.MultiError) as err:
# always ship errors back to caller
log.exception("Actor errored:")
err_msg = pack_error(err)
@ -352,7 +352,8 @@ class Actor:
return cid, recv_chan
async def _process_messages(
self, chan: Channel,
self,
chan: Channel,
treat_as_gen: bool = False,
shield: bool = False,
task_status=trio.TASK_STATUS_IGNORED,
@ -461,7 +462,7 @@ class Actor:
except trio.ClosedResourceError:
log.error(f"{chan} form {chan.uid} broke")
except Exception as err:
except (Exception, trio.MultiError) as err:
# ship any "internal" exception (i.e. one from internal machinery
# not from an rpc task) to parent
log.exception("Actor errored:")
@ -472,7 +473,7 @@ class Actor:
# above to trigger an error at consuming portal "checkpoints"
except trio.Cancelled:
# debugging only
log.debug("Msg loop was cancelled")
log.debug(f"Msg loop was cancelled for {chan}")
raise
finally:
log.debug(