Use early return instead of branching for remote emsd spawning

supervise
Tyler Goodlet 2021-03-22 09:52:22 -04:00
parent fb996bfffb
commit 38471b7b34
1 changed files with 11 additions and 12 deletions

View File

@ -174,22 +174,21 @@ async def maybe_open_emsd(
async with tractor.find_actor('emsd') as portal:
if portal is not None:
yield portal
return
else:
# ask remote daemon tree to spawn it
from .._daemon import spawn_emsd
# ask remote daemon tree to spawn it
from .._daemon import spawn_emsd
async with tractor.find_actor('pikerd') as portal:
async with tractor.find_actor('pikerd') as portal:
assert portal
name = await portal.run(
spawn_emsd,
brokername=brokername,
)
if portal is not None:
async with tractor.wait_for_actor(name) as portal:
yield portal
name = await portal.run(
spawn_emsd,
brokername=brokername,
)
async with tractor.wait_for_actor(name) as portal:
yield portal
@asynccontextmanager