Don't use a context stack for contexts

backup_asyncify_input_modes
Tyler Goodlet 2021-06-25 00:44:02 -04:00
parent b81c538e85
commit 998775dfd9
1 changed files with 13 additions and 5 deletions

View File

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