Mypy fixes

bi_streaming_no_debugger_stuff
Tyler Goodlet 2021-07-08 12:48:34 -04:00
parent 8c927d708d
commit fde52d2464
3 changed files with 10 additions and 11 deletions

View File

@ -64,7 +64,7 @@ async def _invoke(
tb = None
cancel_scope = trio.CancelScope()
cs: trio.CancelScope = None
cs: Optional[trio.CancelScope] = None
ctx = Context(chan, cid)
context: bool = False

View File

@ -391,9 +391,8 @@ class Portal:
else:
raise
_err = None
# deliver context instance and .started() msg value in open
# tuple.
_err: Optional[BaseException] = None
# deliver context instance and .started() msg value in open tuple.
try:
async with trio.open_nursery() as scope_nursery:
ctx = Context(
@ -403,16 +402,13 @@ class Portal:
_recv_chan=recv_chan,
_scope_nursery=scope_nursery,
)
recv_chan._ctx = ctx
# pairs with handling in ``Actor._push_result()``
# recv_chan._ctx = ctx
# await trio.lowlevel.checkpoint()
yield ctx, first
# if not ctx._cancel_called:
# await ctx.result()
# await recv_chan.aclose()
except ContextCancelled as err:
_err = err
if not ctx._cancel_called:
@ -462,7 +458,7 @@ class Portal:
else:
log.info(
f'Context {fn_name} returned '
f'value from callee `{self._result}`'
f'value from callee `{result}`'
)

View File

@ -332,6 +332,8 @@ class Context:
Acts as a form of "relay" for a remote error raised
in the corresponding remote callee task.
'''
assert self._scope_nursery
async def raiser():
raise unpack_error(msg, self.chan)
@ -385,6 +387,7 @@ class Context:
# {'error': trio.Cancelled, cid: "blah"} enough?
# This probably gets into the discussion in
# https://github.com/goodboy/tractor/issues/36
assert self._scope_nursery
self._scope_nursery.cancel_scope.cancel()
if self._recv_chan: