Better tractor startup, runtime detection
parent
877db52162
commit
b1a1b32315
|
@ -68,19 +68,16 @@ async def open_pikerd(
|
||||||
assert _services is None
|
assert _services is None
|
||||||
|
|
||||||
# XXX: this may open a root actor as well
|
# XXX: this may open a root actor as well
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_root_actor(
|
||||||
|
|
||||||
# passed through to ``open_root_actor``
|
# passed through to ``open_root_actor``
|
||||||
name=_root_dname,
|
name=_root_dname,
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
|
|
||||||
# TODO: eventually we should be able to avoid
|
# TODO: eventually we should be able to avoid
|
||||||
# having the root have more then permissions to
|
# having the root have more then permissions to
|
||||||
# spawn other specialized daemons I think?
|
# spawn other specialized daemons I think?
|
||||||
# enable_modules=[__name__],
|
# enable_modules=[__name__],
|
||||||
enable_modules=_root_modules,
|
enable_modules=_root_modules,
|
||||||
|
) as _, tractor.open_nursery() as actor_nursery:
|
||||||
) as actor_nursery:
|
|
||||||
async with trio.open_nursery() as service_nursery:
|
async with trio.open_nursery() as service_nursery:
|
||||||
|
|
||||||
# assign globally for future daemon/task creation
|
# assign globally for future daemon/task creation
|
||||||
|
@ -107,14 +104,13 @@ async def maybe_open_pikerd(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with tractor.find_actor(_root_dname) as portal:
|
async with tractor.find_actor(_root_dname) as portal:
|
||||||
if portal is not None: # pikerd exists
|
assert portal is not None
|
||||||
yield portal
|
yield portal
|
||||||
return
|
return
|
||||||
|
|
||||||
except RuntimeError: # tractor runtime not started yet
|
except (RuntimeError, AssertionError): # tractor runtime not started yet
|
||||||
pass
|
|
||||||
|
|
||||||
# assume pikerd role
|
# presume pikerd role
|
||||||
async with open_pikerd(
|
async with open_pikerd(
|
||||||
loglevel,
|
loglevel,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
Loading…
Reference in New Issue