Set `Context._scope_nursery` on callee side too
Because obviously we probably want to support `allow_overruns` on the remote callee side as well XD Only found the bugs fixed in this patch this thanks to writing a much more exhaustive test set for overrun cases B)ctx_cancel_semantics_and_overruns
parent
f9911c22a4
commit
968f13f9ef
|
@ -205,8 +205,9 @@ async def _invoke(
|
||||||
await chan.send({'functype': 'context', 'cid': cid})
|
await chan.send({'functype': 'context', 'cid': cid})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with cancel_scope as cs:
|
async with trio.open_nursery() as nurse:
|
||||||
ctx._scope = cs
|
ctx._scope_nursery = nurse
|
||||||
|
ctx._scope = nurse.cancel_scope
|
||||||
task_status.started(ctx)
|
task_status.started(ctx)
|
||||||
res = await coro
|
res = await coro
|
||||||
await chan.send({'return': res, 'cid': cid})
|
await chan.send({'return': res, 'cid': cid})
|
||||||
|
@ -240,8 +241,7 @@ async def _invoke(
|
||||||
f'Context entrypoint {func} was terminated:\n{ctx}'
|
f'Context entrypoint {func} was terminated:\n{ctx}'
|
||||||
)
|
)
|
||||||
|
|
||||||
assert cs
|
if ctx.cancelled_caught:
|
||||||
if cs.cancelled_caught:
|
|
||||||
|
|
||||||
# first check for and raise any remote error
|
# first check for and raise any remote error
|
||||||
# before raising any context cancelled case
|
# before raising any context cancelled case
|
||||||
|
@ -252,6 +252,7 @@ async def _invoke(
|
||||||
ctx._maybe_raise_remote_err(re)
|
ctx._maybe_raise_remote_err(re)
|
||||||
|
|
||||||
fname = func.__name__
|
fname = func.__name__
|
||||||
|
cs: trio.CancelScope = ctx._scope
|
||||||
if cs.cancel_called:
|
if cs.cancel_called:
|
||||||
canceller = ctx._cancel_called_remote
|
canceller = ctx._cancel_called_remote
|
||||||
# await _debug.breakpoint()
|
# await _debug.breakpoint()
|
||||||
|
@ -383,7 +384,7 @@ async def _invoke(
|
||||||
# error is probably from above coro running code *not from the
|
# error is probably from above coro running code *not from the
|
||||||
# underlyingn rpc invocation* since a scope was never allocated
|
# underlyingn rpc invocation* since a scope was never allocated
|
||||||
# around actual coroutine await.
|
# around actual coroutine await.
|
||||||
if cs is None:
|
if ctx._scope is None:
|
||||||
# we don't ever raise directly here to allow the
|
# we don't ever raise directly here to allow the
|
||||||
# msg-loop-scheduler to continue running for this
|
# msg-loop-scheduler to continue running for this
|
||||||
# channel.
|
# channel.
|
||||||
|
|
Loading…
Reference in New Issue