Add remote context allocation api to service daemon

This allows for more deterministically managing long running sub-daemon
services under `pikerd` using the new context api from `tractor`.
The contexts are allocated in an async exit stack and torn down at root
daemon termination. Spawn brokerds using this method by changing the
persistence entry point to be a `@tractor.context`.
symbol_search
Tyler Goodlet 2021-05-23 10:53:57 -04:00
parent 27d704b32e
commit c9cf72d554
1 changed files with 1 additions and 2 deletions

View File

@ -18,7 +18,6 @@
Structured, daemon tree service management. Structured, daemon tree service management.
""" """
from functools import partial
from typing import Optional, Union, Callable, Any from typing import Optional, Union, Callable, Any
from contextlib import asynccontextmanager, AsyncExitStack from contextlib import asynccontextmanager, AsyncExitStack
from collections import defaultdict from collections import defaultdict
@ -72,7 +71,7 @@ class Services(BaseModel):
ctx, first = await self.ctx_stack.enter_async_context( ctx, first = await self.ctx_stack.enter_async_context(
portal.open_context( portal.open_context(
target, target,
**kwargs, **kwargs,
) )
) )
return ctx return ctx