Don't use a context stack for contexts
parent
835ea7f046
commit
cc9a720af7
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue