Compare commits
2 Commits
68daa25208
...
8a02f6ea39
| Author | SHA1 | Date |
|---|---|---|
|
|
8a02f6ea39 | |
|
|
09e5de383a |
|
|
@ -67,12 +67,13 @@ async def _setup_persistent_brokerd(
|
||||||
ctx: tractor.Context,
|
ctx: tractor.Context,
|
||||||
brokername: str,
|
brokername: str,
|
||||||
loglevel: str|None = None,
|
loglevel: str|None = None,
|
||||||
|
debug_mode: bool = False,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Allocate a actor-wide service nursery in ``brokerd``
|
Allocate a actor-wide service nursery in `brokerd` such that
|
||||||
such that feeds can be run in the background persistently by
|
feeds can be run in the background persistently by the broker
|
||||||
the broker backend as needed.
|
backend as needed.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# NOTE: we only need to setup logging once (and only) here
|
# NOTE: we only need to setup logging once (and only) here
|
||||||
|
|
@ -94,6 +95,18 @@ async def _setup_persistent_brokerd(
|
||||||
from piker.data import feed
|
from piker.data import feed
|
||||||
assert not feed._bus
|
assert not feed._bus
|
||||||
|
|
||||||
|
if (
|
||||||
|
debug_mode
|
||||||
|
and
|
||||||
|
tractor.current_actor().is_infected_aio()
|
||||||
|
):
|
||||||
|
# NOTE, whenever running `asyncio` in provider's actor
|
||||||
|
# runtime be sure we enabled `breakpoint()` support
|
||||||
|
# for non-`trio.Task` usage.
|
||||||
|
from tractor.devx import maybe_init_greenback
|
||||||
|
await maybe_init_greenback()
|
||||||
|
# breakpoint() # XXX, SHOULD WORK from `trio.Task`!
|
||||||
|
|
||||||
# allocate a nursery to the bus for spawning background
|
# allocate a nursery to the bus for spawning background
|
||||||
# tasks to service client IPC requests, normally
|
# tasks to service client IPC requests, normally
|
||||||
# `tractor.Context` connections to explicitly required
|
# `tractor.Context` connections to explicitly required
|
||||||
|
|
@ -156,18 +169,21 @@ def broker_init(
|
||||||
above.
|
above.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from ..brokers import get_brokermod
|
brokermod: ModuleType = get_brokermod(brokername)
|
||||||
brokermod = get_brokermod(brokername)
|
|
||||||
modpath: str = brokermod.__name__
|
modpath: str = brokermod.__name__
|
||||||
|
spawn_kws: dict = getattr(
|
||||||
start_actor_kwargs['name'] = f'brokerd.{brokername}'
|
brokermod,
|
||||||
start_actor_kwargs.update(
|
'_spawn_kwargs',
|
||||||
getattr(
|
{},
|
||||||
brokermod,
|
|
||||||
'_spawn_kwargs',
|
|
||||||
{},
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
# ^^ NOTE, here we pull any runtime parameters specific
|
||||||
|
# to spawning the sub-actor for the backend. For ex.
|
||||||
|
# both `ib` and `deribit` rely on,
|
||||||
|
# `'infect_asyncio': True,` since they both
|
||||||
|
# use `tractor`'s "infected `asyncio` mode"
|
||||||
|
# for their libs but you could also do something like
|
||||||
|
# `'debug_mode: True` which would be like passing
|
||||||
|
# `--pdb` for just that provider backend.
|
||||||
|
|
||||||
# XXX TODO: make this not so hacky/monkeypatched..
|
# XXX TODO: make this not so hacky/monkeypatched..
|
||||||
# -> we need a sane way to configure the logging level for all
|
# -> we need a sane way to configure the logging level for all
|
||||||
|
|
@ -177,8 +193,7 @@ def broker_init(
|
||||||
|
|
||||||
# lookup actor-enabled modules declared by the backend offering the
|
# lookup actor-enabled modules declared by the backend offering the
|
||||||
# `brokerd` endpoint(s).
|
# `brokerd` endpoint(s).
|
||||||
enabled: list[str]
|
enabled: list[str] = [
|
||||||
enabled = start_actor_kwargs['enable_modules'] = [
|
|
||||||
__name__, # so that eps from THIS mod can be invoked
|
__name__, # so that eps from THIS mod can be invoked
|
||||||
modpath,
|
modpath,
|
||||||
]
|
]
|
||||||
|
|
@ -190,9 +205,13 @@ def broker_init(
|
||||||
subpath: str = f'{modpath}.{submodname}'
|
subpath: str = f'{modpath}.{submodname}'
|
||||||
enabled.append(subpath)
|
enabled.append(subpath)
|
||||||
|
|
||||||
|
datad_kwargs: dict = {
|
||||||
|
'name': f'brokerd.{brokername}',
|
||||||
|
'enable_modules': enabled,
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
brokermod,
|
brokermod,
|
||||||
start_actor_kwargs, # to `ActorNursery.start_actor()`
|
start_actor_kwargs | datad_kwargs | spawn_kws, # to `ActorNursery.start_actor()`
|
||||||
|
|
||||||
# XXX see impl above; contains all (actor global)
|
# XXX see impl above; contains all (actor global)
|
||||||
# setup/teardown expected in all `brokerd` actor instances.
|
# setup/teardown expected in all `brokerd` actor instances.
|
||||||
|
|
@ -226,10 +245,6 @@ async def spawn_brokerd(
|
||||||
**tractor_kwargs,
|
**tractor_kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
brokermod = get_brokermod(brokername)
|
|
||||||
extra_tractor_kwargs = getattr(brokermod, '_spawn_kwargs', {})
|
|
||||||
tractor_kwargs.update(extra_tractor_kwargs)
|
|
||||||
|
|
||||||
# ask `pikerd` to spawn a new sub-actor and manage it under its
|
# ask `pikerd` to spawn a new sub-actor and manage it under its
|
||||||
# actor nursery
|
# actor nursery
|
||||||
from piker.service import (
|
from piker.service import (
|
||||||
|
|
@ -247,8 +262,12 @@ async def spawn_brokerd(
|
||||||
# passed to daemon_fixture_ep(**kwargs)
|
# passed to daemon_fixture_ep(**kwargs)
|
||||||
brokername=brokername,
|
brokername=brokername,
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
|
debug_mode=mngr.debug_mode,
|
||||||
),
|
),
|
||||||
debug_mode=mngr.debug_mode,
|
debug_mode=mngr.debug_mode,
|
||||||
|
# ^TODO, allow overriding this per-daemon from client side?
|
||||||
|
# |_ it's already supported in `tractor` so..
|
||||||
|
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
enable_modules=(
|
enable_modules=(
|
||||||
_data_mods
|
_data_mods
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ dependencies = [
|
||||||
"pyvnc",
|
"pyvnc",
|
||||||
"exchange-calendars>=4.13.1",
|
"exchange-calendars>=4.13.1",
|
||||||
"ib-async>=2.1.0",
|
"ib-async>=2.1.0",
|
||||||
"aeventkit>=2.1.0", # XXX, imports as eventkit?
|
"aeventkit>=2.1.0",
|
||||||
]
|
]
|
||||||
# ------ dependencies ------
|
# ------ dependencies ------
|
||||||
# NOTE, by default we ship only a "headless" deps set bc
|
# NOTE, by default we ship only a "headless" deps set bc
|
||||||
|
|
@ -203,7 +203,7 @@ pyvnc = { git = "https://github.com/regulad/pyvnc.git" }
|
||||||
# xonsh = { git = 'https://github.com/xonsh/xonsh.git', branch = 'main' }
|
# xonsh = { git = 'https://github.com/xonsh/xonsh.git', branch = 'main' }
|
||||||
|
|
||||||
# XXX since, we're like, always hacking new shite all-the-time. Bp
|
# XXX since, we're like, always hacking new shite all-the-time. Bp
|
||||||
tractor = { git = "https://github.com/goodboy/tractor.git", branch ="main" }
|
tractor = { git = "https://github.com/goodboy/tractor.git", branch = "hilevel_serman" }
|
||||||
# tractor = { git = "https://pikers.dev/goodboy/tractor", branch = "piker_pin" }
|
# tractor = { git = "https://pikers.dev/goodboy/tractor", branch = "piker_pin" }
|
||||||
# ------ goodboy ------
|
# ------ goodboy ------
|
||||||
# hackin dev-envs, usually there's something new he's hackin in..
|
# hackin dev-envs, usually there's something new he's hackin in..
|
||||||
|
|
|
||||||
10
uv.lock
10
uv.lock
|
|
@ -1034,7 +1034,7 @@ requires-dist = [
|
||||||
{ name = "tomli", specifier = ">=2.0.1,<3.0.0" },
|
{ name = "tomli", specifier = ">=2.0.1,<3.0.0" },
|
||||||
{ name = "tomli-w", specifier = ">=1.0.0,<2.0.0" },
|
{ name = "tomli-w", specifier = ">=1.0.0,<2.0.0" },
|
||||||
{ name = "tomlkit", git = "https://github.com/pikers/tomlkit.git?branch=piker_pin" },
|
{ name = "tomlkit", git = "https://github.com/pikers/tomlkit.git?branch=piker_pin" },
|
||||||
{ name = "tractor", git = "https://github.com/goodboy/tractor.git?branch=main" },
|
{ name = "tractor", git = "https://github.com/goodboy/tractor.git?branch=hilevel_serman" },
|
||||||
{ name = "trio", specifier = ">=0.27" },
|
{ name = "trio", specifier = ">=0.27" },
|
||||||
{ name = "trio-typing", specifier = ">=0.10.0" },
|
{ name = "trio-typing", specifier = ">=0.10.0" },
|
||||||
{ name = "trio-util", specifier = ">=0.7.0,<0.8.0" },
|
{ name = "trio-util", specifier = ">=0.7.0,<0.8.0" },
|
||||||
|
|
@ -1080,11 +1080,11 @@ uis = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "platformdirs"
|
name = "platformdirs"
|
||||||
version = "4.6.0"
|
version = "4.9.4"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/20/e5/474d0a8508029286b905622e6929470fb84337cfa08f9d09fbb624515249/platformdirs-4.6.0.tar.gz", hash = "sha256:4a13c2db1071e5846c3b3e04e5b095c0de36b2a24be9a3bc0145ca66fce4e328", size = 23433, upload-time = "2026-02-12T14:36:21.288Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/19/56/8d4c30c8a1d07013911a8fdbd8f89440ef9f08d07a1b50ab8ca8be5a20f9/platformdirs-4.9.4.tar.gz", hash = "sha256:1ec356301b7dc906d83f371c8f487070e99d3ccf9e501686456394622a01a934", size = 28737, upload-time = "2026-03-05T18:34:13.271Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/da/10/1b0dcf51427326f70e50d98df21b18c228117a743a1fc515a42f8dc7d342/platformdirs-4.6.0-py3-none-any.whl", hash = "sha256:dd7f808d828e1764a22ebff09e60f175ee3c41876606a6132a688d809c7c9c73", size = 19549, upload-time = "2026-02-12T14:36:19.743Z" },
|
{ url = "https://files.pythonhosted.org/packages/63/d7/97f7e3a6abb67d8080dd406fd4df842c2be0efaf712d1c899c32a075027c/platformdirs-4.9.4-py3-none-any.whl", hash = "sha256:68a9a4619a666ea6439f2ff250c12a853cd1cbd5158d258bd824a7df6be2f868", size = 21216, upload-time = "2026-03-05T18:34:12.172Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1676,7 +1676,7 @@ wheels = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tractor"
|
name = "tractor"
|
||||||
version = "0.1.0a6.dev0"
|
version = "0.1.0a6.dev0"
|
||||||
source = { git = "https://github.com/goodboy/tractor.git?branch=main#e77198bb64f0467a50e251ed140daee439752354" }
|
source = { git = "https://github.com/goodboy/tractor.git?branch=hilevel_serman#52fe3083704a7f26c37abadfdf02592fad2d1f81" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "bidict" },
|
{ name = "bidict" },
|
||||||
{ name = "cffi" },
|
{ name = "cffi" },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue