Don't use a context stack for contexts

wait_on_daemon_portals
Tyler Goodlet 2021-06-25 00:44:02 -04:00
parent 835ea7f046
commit cc9a720af7
1 changed files with 13 additions and 5 deletions

View File

@ -45,6 +45,7 @@ _root_modules = [
class Services(BaseModel): class Services(BaseModel):
actor_n: tractor._trionics.ActorNursery actor_n: tractor._trionics.ActorNursery
service_n: trio.Nursery service_n: trio.Nursery
debug_mode: bool # tractor sub-actor debug mode flag debug_mode: bool # tractor sub-actor debug mode flag
@ -68,13 +69,20 @@ class Services(BaseModel):
daemon and explicitly controlling their lifetimes. daemon and explicitly controlling their lifetimes.
''' '''
ctx, first = await self.ctx_stack.enter_async_context( async def open_context_in_task():
portal.open_context(
async with portal.open_context(
target, target,
**kwargs, **kwargs,
) ) as (ctx, first):
)
return ctx await ctx.result()
await portal.result()
self.service_n.start_soon(open_context_in_task)
return 'yo, dis a daemon yo.'
_services: Optional[Services] = None _services: Optional[Services] = None