forked from goodboy/tractor
Mypy fixes
parent
8c927d708d
commit
fde52d2464
|
@ -64,7 +64,7 @@ async def _invoke(
|
||||||
tb = None
|
tb = None
|
||||||
|
|
||||||
cancel_scope = trio.CancelScope()
|
cancel_scope = trio.CancelScope()
|
||||||
cs: trio.CancelScope = None
|
cs: Optional[trio.CancelScope] = None
|
||||||
|
|
||||||
ctx = Context(chan, cid)
|
ctx = Context(chan, cid)
|
||||||
context: bool = False
|
context: bool = False
|
||||||
|
|
|
@ -391,9 +391,8 @@ class Portal:
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
_err = None
|
_err: Optional[BaseException] = None
|
||||||
# deliver context instance and .started() msg value in open
|
# deliver context instance and .started() msg value in open tuple.
|
||||||
# tuple.
|
|
||||||
try:
|
try:
|
||||||
async with trio.open_nursery() as scope_nursery:
|
async with trio.open_nursery() as scope_nursery:
|
||||||
ctx = Context(
|
ctx = Context(
|
||||||
|
@ -403,16 +402,13 @@ class Portal:
|
||||||
_recv_chan=recv_chan,
|
_recv_chan=recv_chan,
|
||||||
_scope_nursery=scope_nursery,
|
_scope_nursery=scope_nursery,
|
||||||
)
|
)
|
||||||
recv_chan._ctx = ctx
|
|
||||||
|
# pairs with handling in ``Actor._push_result()``
|
||||||
|
# recv_chan._ctx = ctx
|
||||||
|
|
||||||
# await trio.lowlevel.checkpoint()
|
# await trio.lowlevel.checkpoint()
|
||||||
yield ctx, first
|
yield ctx, first
|
||||||
|
|
||||||
# if not ctx._cancel_called:
|
|
||||||
# await ctx.result()
|
|
||||||
|
|
||||||
# await recv_chan.aclose()
|
|
||||||
|
|
||||||
except ContextCancelled as err:
|
except ContextCancelled as err:
|
||||||
_err = err
|
_err = err
|
||||||
if not ctx._cancel_called:
|
if not ctx._cancel_called:
|
||||||
|
@ -462,7 +458,7 @@ class Portal:
|
||||||
else:
|
else:
|
||||||
log.info(
|
log.info(
|
||||||
f'Context {fn_name} returned '
|
f'Context {fn_name} returned '
|
||||||
f'value from callee `{self._result}`'
|
f'value from callee `{result}`'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -332,6 +332,8 @@ class Context:
|
||||||
Acts as a form of "relay" for a remote error raised
|
Acts as a form of "relay" for a remote error raised
|
||||||
in the corresponding remote callee task.
|
in the corresponding remote callee task.
|
||||||
'''
|
'''
|
||||||
|
assert self._scope_nursery
|
||||||
|
|
||||||
async def raiser():
|
async def raiser():
|
||||||
raise unpack_error(msg, self.chan)
|
raise unpack_error(msg, self.chan)
|
||||||
|
|
||||||
|
@ -385,6 +387,7 @@ class Context:
|
||||||
# {'error': trio.Cancelled, cid: "blah"} enough?
|
# {'error': trio.Cancelled, cid: "blah"} enough?
|
||||||
# This probably gets into the discussion in
|
# This probably gets into the discussion in
|
||||||
# https://github.com/goodboy/tractor/issues/36
|
# https://github.com/goodboy/tractor/issues/36
|
||||||
|
assert self._scope_nursery
|
||||||
self._scope_nursery.cancel_scope.cancel()
|
self._scope_nursery.cancel_scope.cancel()
|
||||||
|
|
||||||
if self._recv_chan:
|
if self._recv_chan:
|
||||||
|
|
Loading…
Reference in New Issue