forked from goodboy/tractor
Always reset `._state._ctxvar_Context` to prior
Not sure how I forgot this but, obviously it's correct context-var semantics to revert the current IPC `Context` (set in the latest `.open_context()` block) such that any prior instance is reset.. This ensures the sanity `assert`s pass inside `.msg._ops.maybe_limit_plds()` and just in general ensures for any task that the last opened `Context` is the one returned from `current_ipc_ctx()`.aio_abandons
parent
5739e79645
commit
b72a025d0f
tractor
|
@ -38,6 +38,7 @@ from collections import deque
|
|||
from contextlib import (
|
||||
asynccontextmanager as acm,
|
||||
)
|
||||
from contextvars import Token
|
||||
from dataclasses import (
|
||||
dataclass,
|
||||
field,
|
||||
|
@ -1943,7 +1944,7 @@ async def open_context_from_portal(
|
|||
)
|
||||
assert ctx._remote_func_type == 'context'
|
||||
assert ctx._caller_info
|
||||
_ctxvar_Context.set(ctx)
|
||||
prior_ctx_tok: Token = _ctxvar_Context.set(ctx)
|
||||
|
||||
# placeholder for any exception raised in the runtime
|
||||
# or by user tasks which cause this context's closure.
|
||||
|
@ -2394,6 +2395,9 @@ async def open_context_from_portal(
|
|||
None,
|
||||
)
|
||||
|
||||
# XXX revert to prior IPC-task-ctx scope
|
||||
_ctxvar_Context.reset(prior_ctx_tok)
|
||||
|
||||
|
||||
def mk_context(
|
||||
chan: Channel,
|
||||
|
|
Loading…
Reference in New Issue