Compare commits

..

No commits in common. "35b0c4bef0c9088fc7adfa4536c8e32cab3aec10" and "28ea8e787aef8ab7ff99b34d6ab7cf19306b6b98" have entirely different histories.

3 changed files with 19 additions and 17 deletions

View File

@ -69,10 +69,10 @@ def _unwrap_msg(
__tracebackhide__ = True
try:
return msg['return']
except KeyError as ke:
except KeyError:
# internal error should never get here
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:

View File

@ -19,13 +19,22 @@ Sugary patterns for trio + tractor designs.
'''
from ._mngrs import (
gather_contexts as gather_contexts,
maybe_open_context as maybe_open_context,
maybe_open_nursery as maybe_open_nursery,
gather_contexts,
maybe_open_context,
maybe_open_nursery,
)
from ._broadcast import (
AsyncReceiver as AsyncReceiver,
broadcast_receiver as broadcast_receiver,
BroadcastReceiver as BroadcastReceiver,
Lagged as Lagged,
broadcast_receiver,
BroadcastReceiver,
Lagged,
)
__all__ = [
'gather_contexts',
'broadcast_receiver',
'BroadcastReceiver',
'Lagged',
'maybe_open_context',
'maybe_open_nursery',
]

View File

@ -225,7 +225,6 @@ async def maybe_open_context(
# yielded output
yielded: Any = None
lock_registered: bool = False
# Lock resource acquisition around task racing / ``trio``'s
# scheduler protocol.
@ -233,7 +232,6 @@ async def maybe_open_context(
# to allow re-entrant use cases where one `maybe_open_context()`
# wrapped factor may want to call into another.
lock = _Cache.locks.setdefault(fid, trio.Lock())
lock_registered: bool = True
await lock.acquire()
# 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.set()
if lock_registered:
maybe_lock = _Cache.locks.pop(fid, None)
if maybe_lock is None:
log.error(
f'Resource lock for {fid} ALREADY POPPED?'
)
_Cache.locks.pop(fid)