Skip to content

Commit

Permalink
Propagate trio.MultiErrors up the actor tree
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
goodboy committed Oct 28, 2019
1 parent d406383 commit 95e8f3d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tractor/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -352,7 +352,8 @@ async def send_cmd(
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,
Expand Down Expand Up @@ -461,7 +462,7 @@ async def _process_messages(

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:")
Expand All @@ -472,7 +473,7 @@ async def _process_messages(
# 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(
Expand Down

0 comments on commit 95e8f3d

Please sign in to comment.