Compare commits
No commits in common. "35b0c4bef0c9088fc7adfa4536c8e32cab3aec10" and "28ea8e787aef8ab7ff99b34d6ab7cf19306b6b98" have entirely different histories.
35b0c4bef0
...
28ea8e787a
|
@ -69,10 +69,10 @@ def _unwrap_msg(
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
try:
|
try:
|
||||||
return msg['return']
|
return msg['return']
|
||||||
except KeyError as ke:
|
except KeyError:
|
||||||
# internal error should never get here
|
# internal error should never get here
|
||||||
assert msg.get('cid'), "Received internal error at portal?"
|
assert msg.get('cid'), "Received internal error at portal?"
|
||||||
raise unpack_error(msg, channel) from ke
|
raise unpack_error(msg, channel) from None
|
||||||
|
|
||||||
|
|
||||||
class Portal:
|
class Portal:
|
||||||
|
|
|
@ -19,13 +19,22 @@ Sugary patterns for trio + tractor designs.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from ._mngrs import (
|
from ._mngrs import (
|
||||||
gather_contexts as gather_contexts,
|
gather_contexts,
|
||||||
maybe_open_context as maybe_open_context,
|
maybe_open_context,
|
||||||
maybe_open_nursery as maybe_open_nursery,
|
maybe_open_nursery,
|
||||||
)
|
)
|
||||||
from ._broadcast import (
|
from ._broadcast import (
|
||||||
AsyncReceiver as AsyncReceiver,
|
broadcast_receiver,
|
||||||
broadcast_receiver as broadcast_receiver,
|
BroadcastReceiver,
|
||||||
BroadcastReceiver as BroadcastReceiver,
|
Lagged,
|
||||||
Lagged as Lagged,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'gather_contexts',
|
||||||
|
'broadcast_receiver',
|
||||||
|
'BroadcastReceiver',
|
||||||
|
'Lagged',
|
||||||
|
'maybe_open_context',
|
||||||
|
'maybe_open_nursery',
|
||||||
|
]
|
||||||
|
|
|
@ -225,7 +225,6 @@ async def maybe_open_context(
|
||||||
|
|
||||||
# yielded output
|
# yielded output
|
||||||
yielded: Any = None
|
yielded: Any = None
|
||||||
lock_registered: bool = False
|
|
||||||
|
|
||||||
# Lock resource acquisition around task racing / ``trio``'s
|
# Lock resource acquisition around task racing / ``trio``'s
|
||||||
# scheduler protocol.
|
# scheduler protocol.
|
||||||
|
@ -233,7 +232,6 @@ async def maybe_open_context(
|
||||||
# to allow re-entrant use cases where one `maybe_open_context()`
|
# to allow re-entrant use cases where one `maybe_open_context()`
|
||||||
# wrapped factor may want to call into another.
|
# wrapped factor may want to call into another.
|
||||||
lock = _Cache.locks.setdefault(fid, trio.Lock())
|
lock = _Cache.locks.setdefault(fid, trio.Lock())
|
||||||
lock_registered: bool = True
|
|
||||||
await lock.acquire()
|
await lock.acquire()
|
||||||
|
|
||||||
# XXX: one singleton nursery per actor and we want to
|
# XXX: one singleton nursery per actor and we want to
|
||||||
|
@ -293,9 +291,4 @@ async def maybe_open_context(
|
||||||
_, no_more_users = entry
|
_, no_more_users = entry
|
||||||
no_more_users.set()
|
no_more_users.set()
|
||||||
|
|
||||||
if lock_registered:
|
_Cache.locks.pop(fid)
|
||||||
maybe_lock = _Cache.locks.pop(fid, None)
|
|
||||||
if maybe_lock is None:
|
|
||||||
log.error(
|
|
||||||
f'Resource lock for {fid} ALREADY POPPED?'
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue