Be more pedantic with error handling
parent
899404932a
commit
01bef653c2
|
@ -358,12 +358,14 @@ class Portal:
|
|||
|
||||
fn_mod_path, fn_name = func_deats(func)
|
||||
|
||||
|
||||
try:
|
||||
cid, recv_chan, functype, first_msg = await self._submit(
|
||||
fn_mod_path, fn_name, kwargs)
|
||||
|
||||
assert functype == 'context'
|
||||
|
||||
msg = await recv_chan.receive()
|
||||
|
||||
try:
|
||||
# the "first" value here is delivered by the callee's
|
||||
# ``Context.started()`` call.
|
||||
|
@ -377,14 +379,18 @@ class Portal:
|
|||
raise unpack_error(msg, self.channel)
|
||||
else:
|
||||
raise
|
||||
try:
|
||||
|
||||
# deliver context instance and .started() msg value in open
|
||||
# tuple.
|
||||
ctx = Context(self.channel, cid, _portal=self)
|
||||
try:
|
||||
yield ctx, first
|
||||
|
||||
finally:
|
||||
await recv_chan.aclose()
|
||||
await ctx.cancel()
|
||||
|
||||
finally:
|
||||
await recv_chan.aclose()
|
||||
|
||||
@dataclass
|
||||
class LocalPortal:
|
||||
|
|
|
@ -357,7 +357,8 @@ async def open_nursery(
|
|||
try:
|
||||
if actor is None and is_main_process():
|
||||
|
||||
# if we are the parent process start the actor runtime implicitly
|
||||
# if we are the parent process start the
|
||||
# actor runtime implicitly
|
||||
log.info("Starting actor runtime!")
|
||||
|
||||
# mark us for teardown on exit
|
||||
|
@ -376,7 +377,6 @@ async def open_nursery(
|
|||
async with _open_and_supervise_one_cancels_all_nursery(
|
||||
actor
|
||||
) as anursery:
|
||||
|
||||
yield anursery
|
||||
|
||||
finally:
|
||||
|
|
Loading…
Reference in New Issue