moat-kv 0.70.22__py3-none-any.whl → 0.70.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- build/lib/docs/source/conf.py +201 -0
- build/lib/examples/pathify.py +45 -0
- build/lib/moat/kv/__init__.py +19 -0
- build/lib/moat/kv/_cfg.yaml +97 -0
- build/lib/moat/kv/_main.py +91 -0
- build/lib/moat/kv/actor/__init__.py +98 -0
- build/lib/moat/kv/actor/deletor.py +139 -0
- build/lib/moat/kv/auth/__init__.py +444 -0
- build/lib/moat/kv/auth/_test.py +166 -0
- build/lib/moat/kv/auth/password.py +234 -0
- build/lib/moat/kv/auth/root.py +58 -0
- build/lib/moat/kv/backend/__init__.py +67 -0
- build/lib/moat/kv/backend/mqtt.py +74 -0
- build/lib/moat/kv/backend/serf.py +45 -0
- build/lib/moat/kv/client.py +1025 -0
- build/lib/moat/kv/code.py +236 -0
- build/lib/moat/kv/codec.py +11 -0
- build/lib/moat/kv/command/__init__.py +1 -0
- build/lib/moat/kv/command/acl.py +180 -0
- build/lib/moat/kv/command/auth.py +261 -0
- build/lib/moat/kv/command/code.py +293 -0
- build/lib/moat/kv/command/codec.py +186 -0
- build/lib/moat/kv/command/data.py +265 -0
- build/lib/moat/kv/command/dump/__init__.py +143 -0
- build/lib/moat/kv/command/error.py +149 -0
- build/lib/moat/kv/command/internal.py +248 -0
- build/lib/moat/kv/command/job.py +433 -0
- build/lib/moat/kv/command/log.py +53 -0
- build/lib/moat/kv/command/server.py +114 -0
- build/lib/moat/kv/command/type.py +201 -0
- build/lib/moat/kv/config.py +46 -0
- build/lib/moat/kv/data.py +216 -0
- build/lib/moat/kv/errors.py +561 -0
- build/lib/moat/kv/exceptions.py +126 -0
- build/lib/moat/kv/mock/__init__.py +101 -0
- build/lib/moat/kv/mock/mqtt.py +159 -0
- build/lib/moat/kv/mock/serf.py +250 -0
- build/lib/moat/kv/mock/tracer.py +63 -0
- build/lib/moat/kv/model.py +1069 -0
- build/lib/moat/kv/obj/__init__.py +646 -0
- build/lib/moat/kv/obj/command.py +241 -0
- build/lib/moat/kv/runner.py +1347 -0
- build/lib/moat/kv/server.py +2809 -0
- build/lib/moat/kv/types.py +513 -0
- debian/moat-kv/usr/lib/python3/dist-packages/docs/source/conf.py +201 -0
- debian/moat-kv/usr/lib/python3/dist-packages/examples/pathify.py +45 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/__init__.py +19 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +97 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_main.py +91 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/__init__.py +98 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/deletor.py +139 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/__init__.py +444 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/_test.py +166 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/password.py +234 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/root.py +58 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/__init__.py +67 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +74 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/serf.py +45 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/client.py +1025 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/code.py +236 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/codec.py +11 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/__init__.py +1 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/acl.py +180 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/auth.py +261 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/code.py +293 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/codec.py +186 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/data.py +265 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/dump/__init__.py +143 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/error.py +149 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/internal.py +248 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/job.py +433 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/log.py +53 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/server.py +114 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/type.py +201 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/config.py +46 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/data.py +216 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/errors.py +561 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/exceptions.py +126 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/__init__.py +101 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/mqtt.py +159 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/serf.py +250 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/tracer.py +63 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/model.py +1069 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/__init__.py +646 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/command.py +241 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/runner.py +1347 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/server.py +2809 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/types.py +513 -0
- docs/source/conf.py +201 -0
- examples/pathify.py +45 -0
- moat/kv/__init__.py +1 -0
- moat/kv/_cfg.yaml +97 -0
- moat/kv/_main.py +6 -9
- moat/kv/actor/__init__.py +2 -1
- moat/kv/actor/deletor.py +3 -1
- moat/kv/auth/__init__.py +8 -10
- moat/kv/auth/_test.py +6 -12
- moat/kv/auth/password.py +2 -0
- moat/kv/auth/root.py +2 -0
- moat/kv/backend/__init__.py +1 -0
- moat/kv/backend/mqtt.py +3 -3
- moat/kv/backend/serf.py +1 -0
- moat/kv/client.py +34 -50
- moat/kv/code.py +10 -3
- moat/kv/codec.py +1 -0
- moat/kv/command/acl.py +12 -6
- moat/kv/command/auth.py +5 -2
- moat/kv/command/code.py +10 -23
- moat/kv/command/codec.py +10 -14
- moat/kv/command/data.py +12 -21
- moat/kv/command/dump/__init__.py +4 -2
- moat/kv/command/error.py +5 -12
- moat/kv/command/internal.py +6 -15
- moat/kv/command/job.py +26 -31
- moat/kv/command/log.py +1 -0
- moat/kv/command/server.py +2 -3
- moat/kv/command/type.py +26 -28
- moat/kv/config.py +2 -0
- moat/kv/data.py +8 -7
- moat/kv/errors.py +17 -9
- moat/kv/exceptions.py +1 -7
- moat/kv/mock/__init__.py +9 -5
- moat/kv/mock/mqtt.py +7 -12
- moat/kv/mock/serf.py +6 -9
- moat/kv/mock/tracer.py +2 -4
- moat/kv/model.py +16 -24
- moat/kv/obj/__init__.py +30 -20
- moat/kv/obj/command.py +7 -12
- moat/kv/runner.py +38 -35
- moat/kv/server.py +86 -90
- moat/kv/types.py +5 -8
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.24.dist-info}/METADATA +15 -18
- moat_kv-0.70.24.dist-info/RECORD +137 -0
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.24.dist-info}/WHEEL +1 -1
- moat_kv-0.70.24.dist-info/licenses/LICENSE.txt +14 -0
- moat_kv-0.70.24.dist-info/top_level.txt +9 -0
- moat/kv/_config.yaml +0 -98
- moat_kv-0.70.22.dist-info/LICENSE +0 -3
- moat_kv-0.70.22.dist-info/LICENSE.APACHE2 +0 -202
- moat_kv-0.70.22.dist-info/LICENSE.MIT +0 -20
- moat_kv-0.70.22.dist-info/RECORD +0 -49
- moat_kv-0.70.22.dist-info/top_level.txt +0 -1
moat/kv/obj/__init__.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
Object interface to moat.kv data
|
3
3
|
|
4
4
|
"""
|
5
|
+
from __future__ import annotations
|
5
6
|
|
6
7
|
import heapq
|
7
8
|
import weakref
|
@@ -16,7 +17,16 @@ try:
|
|
16
17
|
except ImportError:
|
17
18
|
from async_generator import asynccontextmanager
|
18
19
|
|
19
|
-
from moat.util import
|
20
|
+
from moat.util import (
|
21
|
+
NoLock,
|
22
|
+
NotGiven,
|
23
|
+
Path,
|
24
|
+
PathLongener,
|
25
|
+
combine_dict,
|
26
|
+
yload,
|
27
|
+
ensure_cfg,
|
28
|
+
CFG,
|
29
|
+
)
|
20
30
|
|
21
31
|
__all__ = ["ClientEntry", "AttrClientEntry", "ClientRoot"]
|
22
32
|
|
@@ -148,7 +158,7 @@ class ClientEntry:
|
|
148
158
|
@property
|
149
159
|
def subpath(self):
|
150
160
|
"""Return the path to this entry, starting with its :class:`ClientRoot` base."""
|
151
|
-
return self._path[len(self.root._path) :]
|
161
|
+
return self._path[len(self.root._path) :]
|
152
162
|
|
153
163
|
@property
|
154
164
|
def all_children(self):
|
@@ -253,7 +263,11 @@ class ClientEntry:
|
|
253
263
|
"""
|
254
264
|
async with NoLock if _locked else self._lock:
|
255
265
|
r = await self.root.client.set(
|
256
|
-
self._path,
|
266
|
+
self._path,
|
267
|
+
chain=self.chain,
|
268
|
+
value=value,
|
269
|
+
nchain=3,
|
270
|
+
idem=True,
|
257
271
|
)
|
258
272
|
if wait:
|
259
273
|
await self.root.wait_chain(r.chain)
|
@@ -261,9 +275,7 @@ class ClientEntry:
|
|
261
275
|
self.chain = r.chain
|
262
276
|
return r
|
263
277
|
|
264
|
-
async def delete(
|
265
|
-
self, _locked=False, nchain=0, chain=True, wait=False, recursive=False
|
266
|
-
):
|
278
|
+
async def delete(self, _locked=False, nchain=0, chain=True, wait=False, recursive=False):
|
267
279
|
"""Delete this node's value.
|
268
280
|
|
269
281
|
This is a coroutine.
|
@@ -419,9 +431,7 @@ class MirrorRoot(ClientEntry):
|
|
419
431
|
self._seen = dict()
|
420
432
|
|
421
433
|
@classmethod
|
422
|
-
async def as_handler(
|
423
|
-
cls, client, cfg=None, key="prefix", subpath=(), name=None, **kw
|
424
|
-
):
|
434
|
+
async def as_handler(cls, client, cfg=None, key="prefix", subpath=(), name=None, **kw):
|
425
435
|
"""Return an (or "the") instance of this class.
|
426
436
|
|
427
437
|
The handler is created if it doesn't exist.
|
@@ -440,13 +450,15 @@ class MirrorRoot(ClientEntry):
|
|
440
450
|
from pathlib import Path as _Path
|
441
451
|
|
442
452
|
md = inspect.getmodule(cls)
|
453
|
+
ensure_cfg("moat.kv")
|
454
|
+
defcfg = CFG.kv.get(cls.CFG)
|
443
455
|
try:
|
444
|
-
f = (_Path(md.__file__).parent / "
|
445
|
-
except
|
456
|
+
f = (_Path(md.__file__).parent / "_nconfig.yaml").open("r")
|
457
|
+
except OSError:
|
446
458
|
pass
|
447
459
|
else:
|
448
460
|
with f:
|
449
|
-
defcfg = yload(f, attr=True).get("kv",{}).get(cls.CFG)
|
461
|
+
defcfg = yload(f, attr=True).get("kv", {}).get(cls.CFG)
|
450
462
|
if cfg:
|
451
463
|
if defcfg:
|
452
464
|
cfg = combine_dict(cfg, defcfg)
|
@@ -461,9 +473,7 @@ class MirrorRoot(ClientEntry):
|
|
461
473
|
name = str(Path("_moat.kv", client.name, cls.CFG, *subpath))
|
462
474
|
|
463
475
|
def make():
|
464
|
-
return client.mirror(
|
465
|
-
cfg[key] + subpath, root_type=cls, need_wait=True, cfg=cfg, **kw
|
466
|
-
)
|
476
|
+
return client.mirror(cfg[key] + subpath, root_type=cls, need_wait=True, cfg=cfg, **kw)
|
467
477
|
|
468
478
|
return await client.unique_helper(name, factory=make)
|
469
479
|
|
@@ -525,7 +535,10 @@ class MirrorRoot(ClientEntry):
|
|
525
535
|
pl = PathLongener(())
|
526
536
|
await self.run_starting()
|
527
537
|
async with self.client._stream(
|
528
|
-
"watch",
|
538
|
+
"watch",
|
539
|
+
nchain=3,
|
540
|
+
path=self._path,
|
541
|
+
fetch=True,
|
529
542
|
) as w:
|
530
543
|
async for r in w:
|
531
544
|
if "path" not in r:
|
@@ -551,9 +564,7 @@ class MirrorRoot(ClientEntry):
|
|
551
564
|
pass
|
552
565
|
|
553
566
|
# update entry
|
554
|
-
entry.chain = (
|
555
|
-
None if val is NotGiven else r.get("chain", None)
|
556
|
-
)
|
567
|
+
entry.chain = None if val is NotGiven else r.get("chain", None)
|
557
568
|
await entry.set_value(val)
|
558
569
|
|
559
570
|
if val is NotGiven and not entry:
|
@@ -620,7 +631,6 @@ class MirrorRoot(ClientEntry):
|
|
620
631
|
|
621
632
|
|
622
633
|
class ClientRoot(MirrorRoot):
|
623
|
-
|
624
634
|
"""
|
625
635
|
This class represents the root of a subsystem's storage.
|
626
636
|
|
moat/kv/obj/command.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface helpers for objects
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import logging
|
4
5
|
import sys
|
@@ -54,9 +55,7 @@ class _InvSub:
|
|
54
55
|
def id_arg(self, proc):
|
55
56
|
if self.id_name is None:
|
56
57
|
return proc
|
57
|
-
return click.argument(
|
58
|
-
self.id_name, type=self.id_typ, callback=self.id_cb, nargs=1
|
59
|
-
)(proc)
|
58
|
+
return click.argument(self.id_name, type=self.id_typ, callback=self.id_cb, nargs=1)(proc)
|
60
59
|
|
61
60
|
def apply_aux(self, proc):
|
62
61
|
for t in self.aux:
|
@@ -106,13 +105,13 @@ def std_command(cli, *a, **kw):
|
|
106
105
|
name=tname,
|
107
106
|
invoke_without_command=True,
|
108
107
|
short_help=tinv.short_help,
|
109
|
-
help="""\
|
110
|
-
Manager for {
|
108
|
+
help=f"""\
|
109
|
+
Manager for {tinv.long_name}s.
|
111
110
|
|
112
111
|
\b
|
113
112
|
Use '… {tname} -' to list all entries.
|
114
113
|
Use '… {tname} NAME' to show details of a single entry.
|
115
|
-
"""
|
114
|
+
""",
|
116
115
|
)
|
117
116
|
@click.argument("name", type=str, nargs=1)
|
118
117
|
@click.pass_context
|
@@ -123,9 +122,7 @@ def std_command(cli, *a, **kw):
|
|
123
122
|
|
124
123
|
if name == "-":
|
125
124
|
if ctx.invoked_subcommand is not None:
|
126
|
-
raise click.BadParameter(
|
127
|
-
"The name '-' triggers a list and precludes subcommands."
|
128
|
-
)
|
125
|
+
raise click.BadParameter("The name '-' triggers a list and precludes subcommands.")
|
129
126
|
cnt = 0
|
130
127
|
for n in this(obj).all_children if tinv.list_recursive else this(obj):
|
131
128
|
cnt += 1
|
@@ -152,9 +149,7 @@ def std_command(cli, *a, **kw):
|
|
152
149
|
else:
|
153
150
|
vv = "-"
|
154
151
|
elif isinstance(vv, dict):
|
155
|
-
vv = " ".join(
|
156
|
-
"%s=%s" % (x, y) for x, y in sorted(vv.items())
|
157
|
-
)
|
152
|
+
vv = " ".join("%s=%s" % (x, y) for x, y in sorted(vv.items()))
|
158
153
|
print("%s %s %s" % (k, kk, vv), file=obj.stdout)
|
159
154
|
else:
|
160
155
|
print("%s %s" % (k, v), file=obj.stdout)
|
moat/kv/runner.py
CHANGED
@@ -3,6 +3,7 @@ This module's job is to run code, resp. to keep it running.
|
|
3
3
|
|
4
4
|
|
5
5
|
"""
|
6
|
+
from __future__ import annotations
|
6
7
|
|
7
8
|
import time
|
8
9
|
from collections.abc import Mapping
|
@@ -131,6 +132,7 @@ for _c in (
|
|
131
132
|
|
132
133
|
_CLASSES["NotGiven"] = NotGiven # ellipsis
|
133
134
|
|
135
|
+
|
134
136
|
class CallAdmin:
|
135
137
|
"""
|
136
138
|
This class collects some standard tasks which async MoaT-KV-embedded
|
@@ -169,9 +171,9 @@ class CallAdmin:
|
|
169
171
|
"""Called by the runner to actually execute the code."""
|
170
172
|
self._logger.debug("Start %s with %s", self._runner._path, self._runner.code)
|
171
173
|
async with (
|
172
|
-
|
173
|
-
|
174
|
-
|
174
|
+
anyio.create_task_group() as tg,
|
175
|
+
AsyncExitStack() as stack,
|
176
|
+
):
|
175
177
|
self._stack = stack
|
176
178
|
self._taskgroup = tg
|
177
179
|
self._runner.scope = sc = tg.cancel_scope
|
@@ -249,7 +251,7 @@ class CallAdmin:
|
|
249
251
|
path = self._path
|
250
252
|
r = await self._err.record_error("run", path, **kw)
|
251
253
|
await self._err.root.wait_chain(r.chain)
|
252
|
-
raise ErrorRecorded
|
254
|
+
raise ErrorRecorded
|
253
255
|
|
254
256
|
async def open_context(self, ctx):
|
255
257
|
return await self._stack.enter_async_context(ctx)
|
@@ -294,9 +296,7 @@ class CallAdmin:
|
|
294
296
|
async with slf.client.watch(path, **kw) as watcher:
|
295
297
|
yield watcher
|
296
298
|
else:
|
297
|
-
raise RuntimeError(
|
298
|
-
f"What should I do with a path marked {path.mark !r}?"
|
299
|
-
)
|
299
|
+
raise RuntimeError(f"What should I do with a path marked {path.mark!r}?")
|
300
300
|
|
301
301
|
with anyio.CancelScope() as sc:
|
302
302
|
slf.scope = sc
|
@@ -318,9 +318,7 @@ class CallAdmin:
|
|
318
318
|
elif msg.get("state", "") == "uptodate":
|
319
319
|
slf.admin._n_watch_seen += 1
|
320
320
|
if slf.admin._n_watch_seen == slf.admin._n_watch:
|
321
|
-
await slf.runner.send_event(
|
322
|
-
ReadyMsg(slf.admin._n_watch_seen)
|
323
|
-
)
|
321
|
+
await slf.runner.send_event(ReadyMsg(slf.admin._n_watch_seen))
|
324
322
|
|
325
323
|
def cancel(slf):
|
326
324
|
if slf.scope is None:
|
@@ -361,7 +359,7 @@ class CallAdmin:
|
|
361
359
|
if path.mark == "r":
|
362
360
|
return await self.send(path, value)
|
363
361
|
elif path.mark:
|
364
|
-
raise RuntimeError(f"What should I do with a path marked {path.mark
|
362
|
+
raise RuntimeError(f"What should I do with a path marked {path.mark!r}")
|
365
363
|
|
366
364
|
if isinstance(path, (tuple, list)):
|
367
365
|
path = Path.build(path)
|
@@ -556,7 +554,9 @@ class RunnerEntry(AttrClientEntry):
|
|
556
554
|
raise RuntimeError(f"already running on {state.node}")
|
557
555
|
code = self.root.code.follow(self.code, create=False)
|
558
556
|
data = combine_dict(
|
559
|
-
self.data or {},
|
557
|
+
self.data or {},
|
558
|
+
{} if code.value is NotGiven else code.value.get("default", {}),
|
559
|
+
deep=True,
|
560
560
|
)
|
561
561
|
|
562
562
|
if code.is_async:
|
@@ -574,9 +574,7 @@ class RunnerEntry(AttrClientEntry):
|
|
574
574
|
|
575
575
|
await state.save(wait=True)
|
576
576
|
if state.node != state.root.name:
|
577
|
-
raise RuntimeError(
|
578
|
-
"Rudely taken away from us.", state.node, state.root.name
|
579
|
-
)
|
577
|
+
raise RuntimeError("Rudely taken away from us.", state.node, state.root.name)
|
580
578
|
|
581
579
|
data["_self"] = calls = CallAdmin(self, state, data)
|
582
580
|
res = await calls._run(code, data)
|
@@ -600,7 +598,11 @@ class RunnerEntry(AttrClientEntry):
|
|
600
598
|
c, self._comment = self._comment, None
|
601
599
|
with anyio.move_on_after(5, shield=True):
|
602
600
|
r = await self.root.err.record_error(
|
603
|
-
"run",
|
601
|
+
"run",
|
602
|
+
self._path,
|
603
|
+
exc=exc,
|
604
|
+
data=self.data,
|
605
|
+
comment=c,
|
604
606
|
)
|
605
607
|
if r is not None:
|
606
608
|
await self.root.err.wait_chain(r.chain)
|
@@ -803,7 +805,9 @@ class StateEntry(AttrClientEntry):
|
|
803
805
|
self.node = None
|
804
806
|
self.backoff = min(20, self.backoff + 1)
|
805
807
|
await self.root.runner.err.record_error(
|
806
|
-
"run",
|
808
|
+
"run",
|
809
|
+
self.runner._path,
|
810
|
+
message="Runner restarted",
|
807
811
|
)
|
808
812
|
await self.save()
|
809
813
|
|
@@ -848,7 +852,7 @@ class StateEntry(AttrClientEntry):
|
|
848
852
|
return
|
849
853
|
elif self.node is None or n == self.root.runner.name:
|
850
854
|
# Owch. Our job got taken away from us.
|
851
|
-
run._comment = f"Cancel: Node set to {self.node
|
855
|
+
run._comment = f"Cancel: Node set to {self.node!r}"
|
852
856
|
run.scope.cancel()
|
853
857
|
elif n is not None:
|
854
858
|
logger.warning(
|
@@ -918,7 +922,8 @@ class StateRoot(MirrorRoot):
|
|
918
922
|
await self.update(val)
|
919
923
|
else:
|
920
924
|
await self.client.msg_send(
|
921
|
-
"run",
|
925
|
+
"run",
|
926
|
+
{"group": self.runner.group, "time": t, "node": self.name},
|
922
927
|
)
|
923
928
|
|
924
929
|
|
@@ -961,9 +966,7 @@ class _BaseRunnerRoot(ClientRoot):
|
|
961
966
|
cfg_ = client._cfg["runner"]
|
962
967
|
else:
|
963
968
|
cfg_ = combine_dict(cfg, client._cfg["runner"])
|
964
|
-
return await super().as_handler(
|
965
|
-
client, subpath=subpath, _subpath=subpath, cfg=cfg_, **kw
|
966
|
-
)
|
969
|
+
return await super().as_handler(client, subpath=subpath, _subpath=subpath, cfg=cfg_, **kw)
|
967
970
|
|
968
971
|
async def run_starting(self):
|
969
972
|
from .code import CodeRoot
|
@@ -984,7 +987,10 @@ class _BaseRunnerRoot(ClientRoot):
|
|
984
987
|
|
985
988
|
async def _state_runner(self):
|
986
989
|
self.state = await StateRoot.as_handler(
|
987
|
-
self.client,
|
990
|
+
self.client,
|
991
|
+
cfg=self._cfg,
|
992
|
+
subpath=self._x_subpath,
|
993
|
+
key="state",
|
988
994
|
)
|
989
995
|
|
990
996
|
@property
|
@@ -1014,7 +1020,7 @@ class _BaseRunnerRoot(ClientRoot):
|
|
1014
1020
|
|
1015
1021
|
Its job is to control which tasks are started.
|
1016
1022
|
"""
|
1017
|
-
raise RuntimeError("You want to override me."
|
1023
|
+
raise RuntimeError("You want to override me.")
|
1018
1024
|
|
1019
1025
|
async def trigger_rescan(self):
|
1020
1026
|
"""Tell the _run_actor task to rescan our job list prematurely"""
|
@@ -1096,9 +1102,7 @@ class AnyRunnerRoot(_BaseRunnerRoot):
|
|
1096
1102
|
def __init__(self, *a, **kw):
|
1097
1103
|
super().__init__(*a, **kw)
|
1098
1104
|
self.group = (
|
1099
|
-
P(self.client.config.server["root"]) + P(self._cfg["name"])
|
1100
|
-
| "any"
|
1101
|
-
| self._path[-1]
|
1105
|
+
P(self.client.config.server["root"]) + P(self._cfg["name"]) | "any" | self._path[-1]
|
1102
1106
|
)
|
1103
1107
|
|
1104
1108
|
def get_node(self, name):
|
@@ -1116,7 +1120,10 @@ class AnyRunnerRoot(_BaseRunnerRoot):
|
|
1116
1120
|
Monitor the Actor state, run a :meth:`_run_now` subtask whenever we're 'it'.
|
1117
1121
|
"""
|
1118
1122
|
async with ClientActor(
|
1119
|
-
self.client,
|
1123
|
+
self.client,
|
1124
|
+
self.name,
|
1125
|
+
topic=self.group,
|
1126
|
+
cfg=self._cfg["actor"],
|
1120
1127
|
) as act:
|
1121
1128
|
self._act = act
|
1122
1129
|
|
@@ -1176,7 +1183,7 @@ class AnyRunnerRoot(_BaseRunnerRoot):
|
|
1176
1183
|
self._stale_times.append(cur)
|
1177
1184
|
if self._stale_times[0] > cur - self.max_age:
|
1178
1185
|
return
|
1179
|
-
if len(self._stale_times) <= 2*self._cfg["actor"]["n_hosts"]+1:
|
1186
|
+
if len(self._stale_times) <= 2 * self._cfg["actor"]["n_hosts"] + 1:
|
1180
1187
|
return
|
1181
1188
|
cut = self._stale_times.pop(0)
|
1182
1189
|
|
@@ -1278,9 +1285,7 @@ class SingleRunnerRoot(_BaseRunnerRoot):
|
|
1278
1285
|
async with anyio.create_task_group() as tg:
|
1279
1286
|
age_q = create_queue(1)
|
1280
1287
|
|
1281
|
-
async with ClientActor(
|
1282
|
-
self.client, self.name, topic=self.group, cfg=self._cfg
|
1283
|
-
) as act:
|
1288
|
+
async with ClientActor(self.client, self.name, topic=self.group, cfg=self._cfg) as act:
|
1284
1289
|
self._act = act
|
1285
1290
|
tg.start_soon(self._age_notifier, age_q)
|
1286
1291
|
await self.spawn(self._run_now)
|
@@ -1330,9 +1335,7 @@ class AllRunnerRoot(SingleRunnerRoot):
|
|
1330
1335
|
def __init__(self, *a, **kw):
|
1331
1336
|
super().__init__(*a, **kw)
|
1332
1337
|
self.group = (
|
1333
|
-
P(self.client.config.server["root"]) + P(self._cfg["name"])
|
1334
|
-
| "all"
|
1335
|
-
| self._path[-1]
|
1338
|
+
P(self.client.config.server["root"]) + P(self._cfg["name"]) | "all" | self._path[-1]
|
1336
1339
|
)
|
1337
1340
|
|
1338
1341
|
async def _state_runner(self):
|