nuspace 0.6.3__tar.gz → 0.6.4__tar.gz
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.
- {nuspace-0.6.3 → nuspace-0.6.4}/CHANGELOG.md +14 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/PKG-INFO +6 -6
- {nuspace-0.6.3 → nuspace-0.6.4}/pyproject.toml +7 -6
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/__init__.py +2 -4
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_telemetry/__init__.py +7 -5
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_telemetry/config.py +18 -4
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_telemetry/send.py +44 -9
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ext/__init__.py +1 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ext/specs.py +31 -12
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/host/presets.py +2 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/host/space.py +1 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/kernel.py +3 -8
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/backends/pool.py +64 -45
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/shell.py +2 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/utils.py +19 -49
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/viewer/feed.py +50 -34
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/viewer/ref.py +26 -12
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/body.py +1 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/kernel.py +6 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/runs.py +87 -17
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/space.py +22 -14
- nuspace-0.6.4/src/nuspace/system/kernel/utils.py +8 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/init.py +18 -9
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/nav.py +59 -39
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/reactions.py +40 -28
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/reload.py +8 -5
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/supervisor.py +46 -45
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/ui/home.py +21 -17
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/ui/search.py +22 -18
- nuspace-0.6.4/src/nuspace/system/utils.py +67 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ui.py +2 -2
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/kernel.py +2 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/specs.py +1 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/conftest.py +4 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_cli.py +2 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_home.py +8 -57
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_kernel.py +131 -3
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_ops_state.py +13 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_reactions.py +101 -35
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_search.py +144 -5
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_services.py +95 -5
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_shapes.py +5 -4
- nuspace-0.6.4/tests/nuspace/test_system_utils.py +129 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_telemetry.py +39 -13
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_ui.py +1 -1
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_web.py +57 -8
- nuspace-0.6.3/src/nuspace/system/kernel/utils.py +0 -24
- nuspace-0.6.3/src/nuspace/system/utils.py +0 -106
- {nuspace-0.6.3 → nuspace-0.6.4}/.gitignore +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/.pre-commit-config.yaml +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/LICENSE.md +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/Makefile +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/README.md +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/examples/space.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/pkgs/ts/nuspace-ui/python/nuspace_ui/build +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_branding/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_branding/header.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_branding/logo.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_branding/palette.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/__main__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/_installed.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/_meta.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/commands/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/commands/init.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/commands/run.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/commands/telemetry.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/commands/verse.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/_cli/main.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/content/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/content/kind.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/content/search.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ext/registry.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/host/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/cell.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/extend.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/pin.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/plane.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/read.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/state.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/stores.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/tree.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/usage.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/ops/utils.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/cell.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/connection.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/contents.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/kernel.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/plane.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/reroot.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/space.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/state.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/shapes/states.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/backends/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/backends/async_.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/backends/base.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/backends/mp.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/device.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/env.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/session.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/sidebar/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/sidebar/feed.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/sidebar/interactions.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/sidebar/ref.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/viewer/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/devices/web/viewer/interactions.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/info.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/dispatch.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/envs.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/out.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/kernel/reconcile.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/services/bootstrap.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/ui/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/ui/seed.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/src/nuspace/system/ui/settings.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_ext/nuspace_testing/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_ext/pyproject.toml +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/__init__.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/actions.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/contents.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/kernel_envs.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/made.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/_lib/_support/probe.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_content.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_host.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_ops_kernel.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_ops_structure.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_packaging.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_session_pipe.py +0 -0
- {nuspace-0.6.3 → nuspace-0.6.4}/tests/nuspace/test_settings.py +0 -0
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## Packages shipped from this repo
|
|
4
4
|
|
|
5
|
-
- **nuspace** (the runtime, the `nuspace` command) — 0.6.
|
|
6
|
-
- **nuspace-ui** (the compiled web bundle) — 0.6.
|
|
5
|
+
- **nuspace** (the runtime, the `nuspace` command) — 0.6.4
|
|
6
|
+
- **nuspace-ui** (the compiled web bundle) — 0.6.4
|
|
7
7
|
|
|
8
8
|
Below is the changelog for **nuspace** - the full commit stream. Newest first.
|
|
9
9
|
The `nuspace-ui` wheel is the same source tree's vite output and is not tracked
|
|
10
10
|
separately here.
|
|
11
11
|
|
|
12
|
+
## 0.6.4 - 2026-11-07
|
|
13
|
+
|
|
14
|
+
- Release nuspace and nuspace-ui 0.6.4 on nu 0.7.1, virtuals 0.2.1 and ui-kit 0.4.0
|
|
15
|
+
- Telemetry sends only known nuspace events and stays off in every major CI
|
|
16
|
+
- Cmd+Enter at the end of text leaves no empty line behind
|
|
17
|
+
- Writing keeps to prose islands: arrows stop at other cells, input lines join in
|
|
18
|
+
- Plane menus share one layout; sidebar menu gains copy id and close items
|
|
19
|
+
- Text cells read as one document: arrows cross seams, Backspace merges, Cmd+Enter splits
|
|
20
|
+
- Writing in a plane: honest hints, slash in empty text, arrows across text cells
|
|
21
|
+
- Move onto the new reactive flows; failing arms now restart, isolate or fail their run
|
|
22
|
+
- Workers come from the hardened pool: one stop grace, no orphans, clean exit causes
|
|
23
|
+
|
|
12
24
|
## 0.6.3 - 2026-11-05
|
|
13
25
|
|
|
14
26
|
- Release nuspace and nuspace-ui 0.6.3 on nu 0.7.0 and virtuals 0.2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: nuspace
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.4
|
|
4
4
|
Summary: Computational space for your data and tools.
|
|
5
5
|
Project-URL: Repository, https://github.com/nustackdev/nuspace
|
|
6
6
|
Author-email: Gor Arakelyan <gorarkln@gmail.com>
|
|
@@ -17,16 +17,16 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Requires-Dist: certifi>=2023.7.22
|
|
19
19
|
Requires-Dist: click>=8.0
|
|
20
|
-
Requires-Dist: nucore>=0.7.
|
|
21
|
-
Requires-Dist: nuspace-ui>=0.6.
|
|
22
|
-
Requires-Dist: nustd[kv,mp-pool,proxy,ui,valkey]>=0.7.
|
|
20
|
+
Requires-Dist: nucore>=0.7.1
|
|
21
|
+
Requires-Dist: nuspace-ui>=0.6.4
|
|
22
|
+
Requires-Dist: nustd[kv,mp-pool,proxy,ui,valkey]>=0.7.1
|
|
23
23
|
Requires-Dist: nuverse>=0.3.5
|
|
24
24
|
Requires-Dist: rich-click>=1.6
|
|
25
25
|
Requires-Dist: rich>=10.7
|
|
26
26
|
Requires-Dist: typing-extensions>=4.7.0
|
|
27
|
-
Requires-Dist: virtuals-py[redis]>=0.2.
|
|
27
|
+
Requires-Dist: virtuals-py[redis]>=0.2.1
|
|
28
28
|
Provides-Extra: all
|
|
29
|
-
Requires-Dist: nustd[all]>=0.7.
|
|
29
|
+
Requires-Dist: nustd[all]>=0.7.1; extra == 'all'
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
32
32
|
<div align="center">
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nuspace"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.4"
|
|
8
8
|
description = "Computational space for your data and tools."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "AGPL-3.0-or-later"
|
|
@@ -14,14 +14,14 @@ dependencies = [
|
|
|
14
14
|
# The fabrics a space runs on, nothing more: kv for the store, valkey for
|
|
15
15
|
# its change notifications, ui for the browser, mp_pool for the workers,
|
|
16
16
|
# proxy (invisibles) for the worker's session.
|
|
17
|
-
"nucore>=0.7.
|
|
18
|
-
"nustd[kv,ui,valkey,mp_pool,proxy]>=0.7.
|
|
17
|
+
"nucore>=0.7.1",
|
|
18
|
+
"nustd[kv,ui,valkey,mp_pool,proxy]>=0.7.1",
|
|
19
19
|
# The store's change notifications run over virtuals' redis backend.
|
|
20
|
-
"virtuals-py[redis]>=0.2.
|
|
20
|
+
"virtuals-py[redis]>=0.2.1",
|
|
21
21
|
# The compiled web bundle. A separate distribution only because PyPI caps
|
|
22
22
|
# project size and a SPA rebuilt on every UI tweak would eat the quota --
|
|
23
23
|
# not optional. `pip install nuspace` gives you the browser.
|
|
24
|
-
"nuspace-ui>=0.6.
|
|
24
|
+
"nuspace-ui>=0.6.4",
|
|
25
25
|
# The everyday Planes and Cells. A plugin like any other, found through
|
|
26
26
|
# its entry point, but every space ships with it.
|
|
27
27
|
"nuverse>=0.3.5",
|
|
@@ -55,7 +55,7 @@ classifiers = [
|
|
|
55
55
|
[project.optional-dependencies]
|
|
56
56
|
# Every nustd fabric and kv backend, for cells that reach past the defaults.
|
|
57
57
|
all = [
|
|
58
|
-
"nustd[all]>=0.7.
|
|
58
|
+
"nustd[all]>=0.7.1",
|
|
59
59
|
]
|
|
60
60
|
|
|
61
61
|
[project.urls]
|
|
@@ -76,6 +76,7 @@ exclude = [
|
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
[tool.uv.sources]
|
|
79
|
+
virtuals-py = { path = "../virtuals", editable = true }
|
|
79
80
|
nuspace-ui = { path = "./pkgs/ts/nuspace-ui", editable = true }
|
|
80
81
|
nucore = { path = "../nu", editable = true }
|
|
81
82
|
nustd = { path = "../nu/pkgs/nustd", editable = true }
|
|
@@ -5,8 +5,7 @@ What a host and a program need, without knowing the layers:
|
|
|
5
5
|
- :func:`open_space`, and what an installed package registers with: an
|
|
6
6
|
:class:`Extension` of :class:`PlaneSpec`, :class:`CellSpec` and
|
|
7
7
|
:class:`ContentSpec` (the store's own shapes are ``shapes.Plane`` and
|
|
8
|
-
``shapes.Cell``)
|
|
9
|
-
document editing works on;
|
|
8
|
+
``shapes.Cell``);
|
|
10
9
|
- :class:`Content`, a kind of findable item, ``class
|
|
11
10
|
TextContent(nuspace.Content[Text], name="Text")``, registered through a
|
|
12
11
|
:class:`ContentSpec` (:mod:`nuspace.content`);
|
|
@@ -23,7 +22,7 @@ Workers import this package: nothing here may pull in a server.
|
|
|
23
22
|
|
|
24
23
|
from nuspace import content, ops, shapes, ui
|
|
25
24
|
from nuspace.content import Content
|
|
26
|
-
from nuspace.ext import
|
|
25
|
+
from nuspace.ext import CellSpec, ContentSpec, Extension, PlaneSpec
|
|
27
26
|
from nuspace.host import open_space
|
|
28
27
|
from nuspace.ops import env
|
|
29
28
|
from nuspace.shapes import CellState, PlaneState, Space, States
|
|
@@ -38,7 +37,6 @@ from nuspace.system.services import (
|
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
__all__ = [
|
|
41
|
-
"TEXT_CELL",
|
|
42
40
|
"CellSpec",
|
|
43
41
|
"CellState",
|
|
44
42
|
"Content",
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
What is sent: ``first_run`` once per user and ``space_opened`` per open, by
|
|
9
9
|
the host however the space is opened (:func:`.opened`), ``space_loaded`` per
|
|
10
10
|
page load in the browser (through the web device, never from the browser
|
|
11
|
-
itself),
|
|
11
|
+
itself), ``plane_created``, ``plane_removed``, ``cell_created``,
|
|
12
12
|
``cell_removed`` by the ops that do it, in whatever process runs them
|
|
13
|
-
(:mod:`nuspace.ops.usage`)
|
|
14
|
-
|
|
13
|
+
(:mod:`nuspace.ops.usage`), and the ``quickstart_*`` steps nuverse tracks
|
|
14
|
+
through those ops. Each carries the versions and the machine's kind,
|
|
15
|
+
nothing about the space. Those names, :data:`.send.EVENTS`, are all that is
|
|
16
|
+
ever sent: any other is dropped before it is queued.
|
|
15
17
|
|
|
16
18
|
Stdlib only and silent on every failure. Queuing is free and never sends:
|
|
17
19
|
the sender drops everything when telemetry is off, on a dev install, under
|
|
@@ -28,14 +30,14 @@ from .config import (
|
|
|
28
30
|
set_telemetry,
|
|
29
31
|
telemetry_enabled,
|
|
30
32
|
)
|
|
31
|
-
from .send import PREFIX, base_properties,
|
|
33
|
+
from .send import EVENTS, PREFIX, base_properties, first_run, flush, opened, track
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
__all__ = [
|
|
35
37
|
"ENV",
|
|
38
|
+
"EVENTS",
|
|
36
39
|
"PREFIX",
|
|
37
40
|
"base_properties",
|
|
38
|
-
"capture",
|
|
39
41
|
"config_path",
|
|
40
42
|
"distinct_id",
|
|
41
43
|
"env_override",
|
|
@@ -7,8 +7,9 @@ test or a sandbox pointing ``HOME`` elsewhere gets its own.
|
|
|
7
7
|
|
|
8
8
|
The environment only ever turns telemetry off, whatever the file says:
|
|
9
9
|
``NUSPACE_TELEMETRY`` set to ``0``, ``false`` or ``off``, ``DO_NOT_TRACK``
|
|
10
|
-
set to anything but that (the cross tool convention), or ``CI``
|
|
11
|
-
|
|
10
|
+
set to anything but that (the cross tool convention), or ``CI`` or a major
|
|
11
|
+
CI's own variable (``GITHUB_ACTIONS``, ``JENKINS_URL``, ...) set the same
|
|
12
|
+
way, so nobody's pipeline is counted as use.
|
|
12
13
|
"""
|
|
13
14
|
|
|
14
15
|
from __future__ import annotations
|
|
@@ -42,8 +43,21 @@ ENV = "NUSPACE_TELEMETRY"
|
|
|
42
43
|
#: What ``NUSPACE_TELEMETRY`` reads as off, case ignored.
|
|
43
44
|
_OFF = frozenset({"0", "false", "off", "no"})
|
|
44
45
|
|
|
45
|
-
#: Conventions that turn telemetry off when set to anything but empty or off
|
|
46
|
-
|
|
46
|
+
#: Conventions that turn telemetry off when set to anything but empty or off:
|
|
47
|
+
#: the cross tool one, then ``CI`` and the variables CIs set of their own.
|
|
48
|
+
_OFF_WHEN_SET = (
|
|
49
|
+
"DO_NOT_TRACK",
|
|
50
|
+
"CI",
|
|
51
|
+
"GITHUB_ACTIONS",
|
|
52
|
+
"GITLAB_CI",
|
|
53
|
+
"BUILDKITE",
|
|
54
|
+
"CIRCLECI",
|
|
55
|
+
"TF_BUILD",
|
|
56
|
+
"JENKINS_URL",
|
|
57
|
+
"TEAMCITY_VERSION",
|
|
58
|
+
"CODEBUILD_BUILD_ID",
|
|
59
|
+
"BITBUCKET_BUILD_NUMBER",
|
|
60
|
+
)
|
|
47
61
|
|
|
48
62
|
|
|
49
63
|
def home() -> Path:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Fire and forget PostHog capture, no dependency beyond the stdlib.
|
|
2
2
|
|
|
3
|
-
One sender thread per process, fed by a bounded queue. :func:`
|
|
3
|
+
One sender thread per process, fed by a bounded queue. :func:`track`
|
|
4
4
|
puts the event's name and time on the queue and returns, O(1): it never
|
|
5
5
|
waits, never touches the network or the disk, and drops the event when the
|
|
6
6
|
queue is full. The thread does the rest, the properties, the id, the opt out
|
|
@@ -9,9 +9,14 @@ and the JSON, and drains what is queued into one ``/batch/`` POST at a time. Eve
|
|
|
9
9
|
breaks because of telemetry. At exit the thread gets a short grace to send
|
|
10
10
|
what is left.
|
|
11
11
|
|
|
12
|
+
Only nuspace's own events are ever queued: a name not in :data:`EVENTS`,
|
|
13
|
+
or anything but a str, is dropped before it reaches the queue, so no caller
|
|
14
|
+
can send a name of its own.
|
|
15
|
+
|
|
12
16
|
Nothing is sent when telemetry is off (see :mod:`.config`: the flag, or
|
|
13
|
-
``NUSPACE_TELEMETRY``, ``DO_NOT_TRACK
|
|
14
|
-
|
|
17
|
+
``NUSPACE_TELEMETRY``, ``DO_NOT_TRACK``, ``CI`` or a CI's own variable), on
|
|
18
|
+
a dev install, or with no token: the thread checks before each POST and
|
|
19
|
+
drops the batch. ``NUSPACE_POSTHOG_TOKEN`` and ``NUSPACE_POSTHOG_HOST`` point it at
|
|
15
20
|
another PostHog project, eg to test.
|
|
16
21
|
"""
|
|
17
22
|
|
|
@@ -40,10 +45,10 @@ if TYPE_CHECKING:
|
|
|
40
45
|
|
|
41
46
|
|
|
42
47
|
__all__ = [
|
|
48
|
+
"EVENTS",
|
|
43
49
|
"FIRST_RUN_EVENT",
|
|
44
50
|
"PREFIX",
|
|
45
51
|
"base_properties",
|
|
46
|
-
"capture",
|
|
47
52
|
"first_run",
|
|
48
53
|
"flush",
|
|
49
54
|
"opened",
|
|
@@ -65,6 +70,28 @@ _BATCH_PATH = "/batch/"
|
|
|
65
70
|
#: What every event is sent as: the product, then what happened.
|
|
66
71
|
PREFIX = "nuspace_"
|
|
67
72
|
|
|
73
|
+
#: Every event that may be sent, by its name before :data:`PREFIX`. Nothing else ever is.
|
|
74
|
+
EVENTS = frozenset(
|
|
75
|
+
{
|
|
76
|
+
"first_run",
|
|
77
|
+
"space_opened",
|
|
78
|
+
"space_loaded",
|
|
79
|
+
"plane_created",
|
|
80
|
+
"plane_removed",
|
|
81
|
+
"cell_created",
|
|
82
|
+
"cell_removed",
|
|
83
|
+
# nuverse's quickstart, through ``nuspace.ops.track``.
|
|
84
|
+
"quickstart_demo_opened",
|
|
85
|
+
"quickstart_page_made",
|
|
86
|
+
"quickstart_edited",
|
|
87
|
+
"quickstart_put_back",
|
|
88
|
+
"quickstart_moved",
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
#: :data:`EVENTS` as sent, prefixed.
|
|
93
|
+
_SENT = frozenset(f"{PREFIX}{event}" for event in EVENTS)
|
|
94
|
+
|
|
68
95
|
#: Sent once per user, retried on every open until PostHog acks it.
|
|
69
96
|
FIRST_RUN_EVENT = f"{PREFIX}first_run"
|
|
70
97
|
|
|
@@ -253,11 +280,16 @@ def _the_sender() -> _Sender:
|
|
|
253
280
|
|
|
254
281
|
|
|
255
282
|
def _queue(event: str, on_success: Callable[[], None] | None) -> None:
|
|
256
|
-
|
|
283
|
+
"""Put ``event``, a prefixed name, on the queue. Every send goes through here.
|
|
284
|
+
|
|
285
|
+
A name not in :data:`EVENTS`, or anything but a str, is dropped.
|
|
286
|
+
"""
|
|
287
|
+
if isinstance(event, str) and event in _SENT:
|
|
288
|
+
_the_sender().put((event, time.time(), on_success))
|
|
257
289
|
|
|
258
290
|
|
|
259
|
-
def
|
|
260
|
-
"""Queue ``event
|
|
291
|
+
def _capture(event: str) -> None:
|
|
292
|
+
"""Queue ``event``, a prefixed name, for the sender thread. O(1), never waits, never raises."""
|
|
261
293
|
try:
|
|
262
294
|
_queue(event, None)
|
|
263
295
|
except Exception: # noqa: S110
|
|
@@ -265,9 +297,12 @@ def capture(event: str) -> None:
|
|
|
265
297
|
|
|
266
298
|
|
|
267
299
|
def track(event: str) -> None:
|
|
268
|
-
"""
|
|
300
|
+
"""Queue ``event`` as nuspace's own, eg ``plane_created``. Never raises.
|
|
301
|
+
|
|
302
|
+
Anything not in :data:`EVENTS`, or not a str, is dropped.
|
|
303
|
+
"""
|
|
269
304
|
if isinstance(event, str):
|
|
270
|
-
|
|
305
|
+
_capture(f"{PREFIX}{event}")
|
|
271
306
|
|
|
272
307
|
|
|
273
308
|
def flush(timeout: float = _EXIT_GRACE_SECONDS) -> bool:
|
|
@@ -27,13 +27,12 @@ from .registry import (
|
|
|
27
27
|
short_name,
|
|
28
28
|
space_registry,
|
|
29
29
|
)
|
|
30
|
-
from .specs import EMPTY_PLANE,
|
|
30
|
+
from .specs import EMPTY_PLANE, CellSpec, ContentSpec, PlaneSpec
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
__all__ = [
|
|
34
34
|
"EMPTY_PLANE",
|
|
35
35
|
"GROUP",
|
|
36
|
-
"TEXT_CELL",
|
|
37
36
|
"CellSpec",
|
|
38
37
|
"ContentSpec",
|
|
39
38
|
"Extension",
|
|
@@ -20,12 +20,7 @@ if TYPE_CHECKING:
|
|
|
20
20
|
from nuspace.content import Content
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
__all__ = ["EMPTY_PLANE", "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
#: The ``nuverse.text`` Cell: nuspace's document editing works on its cells.
|
|
27
|
-
#: See :class:`CellSpec`.
|
|
28
|
-
TEXT_CELL = "nuverse.text"
|
|
23
|
+
__all__ = ["EMPTY_PLANE", "CellSpec", "ContentSpec", "PlaneSpec"]
|
|
29
24
|
|
|
30
25
|
|
|
31
26
|
@dataclass(frozen=True)
|
|
@@ -91,12 +86,18 @@ EMPTY_PLANE = PlaneSpec(
|
|
|
91
86
|
class CellSpec:
|
|
92
87
|
"""Source for one cell, offered from the ``/`` menu.
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
one
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
A cell made from it keeps the spec's classes: the protocols it promises,
|
|
90
|
+
which the browser's sugar binds to, never to which spec made a cell. A
|
|
91
|
+
class is a name, its promise written here. ``prose``: the cell draws
|
|
92
|
+
exactly one document that registers a kit document handle (a kit
|
|
93
|
+
``MarkdownRef`` does on its own), and its value is markdown. Any spec
|
|
94
|
+
whose cell keeps that promise declares it, whoever wrote it. A cell made
|
|
95
|
+
from no spec, or from one no longer installed, has no classes and gets
|
|
96
|
+
the plane's core behaviour only.
|
|
97
|
+
|
|
98
|
+
One spec per class is its default, what typing on the input line
|
|
99
|
+
creates: a spec claims it with ``default_for``. When two installed specs
|
|
100
|
+
claim the same class, the first in registration order wins, no error.
|
|
100
101
|
|
|
101
102
|
Args:
|
|
102
103
|
name: The new cell's name. Installed by a package, it registers
|
|
@@ -111,6 +112,13 @@ class CellSpec:
|
|
|
111
112
|
come last, under no heading.
|
|
112
113
|
icon: What the menu draws beside it, spelled as :class:`PlaneSpec`'s
|
|
113
114
|
``icon``. ``""`` for the default.
|
|
115
|
+
classes: The protocols its cells keep, ``("prose",)``.
|
|
116
|
+
default_for: The classes it is the default of, each one of
|
|
117
|
+
``classes``.
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
TypeError: ``classes`` or ``default_for`` is a bare string.
|
|
121
|
+
ValueError: ``default_for`` names a class not in ``classes``.
|
|
114
122
|
"""
|
|
115
123
|
|
|
116
124
|
name: str
|
|
@@ -119,6 +127,17 @@ class CellSpec:
|
|
|
119
127
|
description: str = ""
|
|
120
128
|
group: str = ""
|
|
121
129
|
icon: str = ""
|
|
130
|
+
classes: tuple[str, ...] = ()
|
|
131
|
+
default_for: tuple[str, ...] = ()
|
|
132
|
+
|
|
133
|
+
def __post_init__(self) -> None:
|
|
134
|
+
if isinstance(self.classes, str) or isinstance(self.default_for, str):
|
|
135
|
+
msg = f"CellSpec {self.name!r}: classes and default_for are tuples, eg ('prose',)"
|
|
136
|
+
raise TypeError(msg)
|
|
137
|
+
stray = [c for c in self.default_for if c not in self.classes]
|
|
138
|
+
if stray:
|
|
139
|
+
msg = f"CellSpec {self.name!r}: default_for {stray} not among classes {self.classes}"
|
|
140
|
+
raise ValueError(msg)
|
|
122
141
|
|
|
123
142
|
|
|
124
143
|
@dataclass(frozen=True)
|
|
@@ -23,7 +23,7 @@ from nuspace import ops
|
|
|
23
23
|
from nuspace.ext.registry import registered_name
|
|
24
24
|
from nuspace.ops.utils import atomic
|
|
25
25
|
from nuspace.shapes import Space
|
|
26
|
-
from nuspace.system.utils import
|
|
26
|
+
from nuspace.system.utils import snap
|
|
27
27
|
|
|
28
28
|
from .space import open_space
|
|
29
29
|
|
|
@@ -165,7 +165,7 @@ def with_plane(
|
|
|
165
165
|
]
|
|
166
166
|
if web and open_browser:
|
|
167
167
|
steps.append(Browse(nu.Str(f"http://{host}:{port}/") + pid, host, port))
|
|
168
|
-
return nu.Sequential(*steps,
|
|
168
|
+
return nu.Sequential(*steps, nu.Park())
|
|
169
169
|
|
|
170
170
|
body = nu.let("", opened)
|
|
171
171
|
if not web:
|
|
@@ -50,7 +50,6 @@ from nuspace.system.services.nav import clear_connections
|
|
|
50
50
|
from nuspace.system.ui.home import ensure_home
|
|
51
51
|
from nuspace.system.ui.search import ensure_search
|
|
52
52
|
from nuspace.system.ui.settings import ensure_settings
|
|
53
|
-
from nuspace.system.utils import park
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
if TYPE_CHECKING:
|
|
@@ -157,7 +156,7 @@ def open_space(
|
|
|
157
156
|
)
|
|
158
157
|
factories = _with_session(factories, web_envs)
|
|
159
158
|
arms.append(served)
|
|
160
|
-
arms.append(
|
|
159
|
+
arms.append(nu.Park() if body is None else body)
|
|
161
160
|
beside = arms[0] if len(arms) == 1 else nu.Race(*arms)
|
|
162
161
|
kwargs = {} if name is None else {"name": name}
|
|
163
162
|
return open_kernel(
|
|
@@ -20,11 +20,10 @@ from __future__ import annotations
|
|
|
20
20
|
from typing import TYPE_CHECKING
|
|
21
21
|
|
|
22
22
|
import nu
|
|
23
|
-
import nustd.kv
|
|
24
23
|
from nuspace.shapes import Space
|
|
25
24
|
|
|
26
25
|
from .read import cell_plane, cells, plane_exists
|
|
27
|
-
from .utils import MintId, atomic, listed
|
|
26
|
+
from .utils import MintId, atomic, listed, snapshot
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
if TYPE_CHECKING:
|
|
@@ -86,10 +85,6 @@ def plane_live(plane_id: nu.StrArg) -> nu.List:
|
|
|
86
85
|
return listed(_kernel.planes_running[plane_id].runs)
|
|
87
86
|
|
|
88
87
|
|
|
89
|
-
def _snap(term: nu.Nu) -> nu.Nu:
|
|
90
|
-
return nustd.kv.Snapshot(term, scope=Space)
|
|
91
|
-
|
|
92
|
-
|
|
93
88
|
# --- Running -------------------------------------------------------------------
|
|
94
89
|
|
|
95
90
|
|
|
@@ -266,8 +261,8 @@ def _until_ended(run_id: nu.StrArg) -> nu.Nu:
|
|
|
266
261
|
Woken by its plane's live runs, which it leaves in the same commit.
|
|
267
262
|
"""
|
|
268
263
|
live = _kernel.planes_running[_kernel.runs[run_id].plane.fallback("")].runs
|
|
269
|
-
return nu.
|
|
270
|
-
|
|
264
|
+
return nu.WaitUntil(
|
|
265
|
+
snapshot(live.on_children_change()), snapshot(_kernel.running.contains(run_id).not_())
|
|
271
266
|
)
|
|
272
267
|
|
|
273
268
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""What the process backends share: workers from the pool, each cell run a blocking request on one.
|
|
2
2
|
|
|
3
|
-
Both sit on ``nustd.mp_pool
|
|
4
|
-
|
|
3
|
+
Both sit on ``nustd.mp_pool``, unchanged: a worker is a pool process, a
|
|
4
|
+
warm spare when the pool keeps some (a cold launch when there is none), its
|
|
5
5
|
``handle`` the pool's id as a str. The two differ only in how many workers
|
|
6
6
|
a plane run gets and when one is let go, so this base keeps the books and a
|
|
7
7
|
subclass decides placement.
|
|
@@ -9,20 +9,23 @@ subclass decides placement.
|
|
|
9
9
|
Books, per plane run: its living workers, and per worker the cell runs
|
|
10
10
|
placed on it. A cell run's body runs as a blocking request on its worker
|
|
11
11
|
(``mp_pool``'s exec), so its arm lives as long as the body does, and a
|
|
12
|
-
worker that dies surfaces as ``WorkerGone`` on every request pending there
|
|
13
|
-
all of the run's cells with ``async``, the one with
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
worker that dies surfaces as ``WorkerGone`` on every request pending there,
|
|
13
|
+
with its exit code: all of the run's cells with ``async``, the one with
|
|
14
|
+
``mp``. The pool's ``cause`` says whose end it was: ``stopped`` or
|
|
15
|
+
``killed`` is the pool's own doing, so the backend letting go and no loss;
|
|
16
|
+
anything else (``crashed``, an outside signal included) is a loss, reported
|
|
17
|
+
with the exit code. Letting go is the pool's ``stop``: the worker tears down
|
|
18
|
+
within the pool's grace, killed if it will not.
|
|
16
19
|
"""
|
|
17
20
|
|
|
18
21
|
from __future__ import annotations
|
|
19
22
|
|
|
20
23
|
import asyncio
|
|
24
|
+
import contextlib
|
|
21
25
|
from typing import TYPE_CHECKING
|
|
22
26
|
|
|
23
27
|
from nuspace.ops.utils import mint_ordered_id
|
|
24
|
-
from nustd.mp_pool import UnknownWorker, WorkerGone, WorkerPool
|
|
25
|
-
from nustd.mp_pool.presets import Spares
|
|
28
|
+
from nustd.mp_pool import Interrupted, UnknownWorker, WorkerGone, WorkerPool
|
|
26
29
|
|
|
27
30
|
from .base import Backend
|
|
28
31
|
|
|
@@ -34,53 +37,48 @@ if TYPE_CHECKING:
|
|
|
34
37
|
|
|
35
38
|
__all__ = ["PoolBackend", "PoolWorker"]
|
|
36
39
|
|
|
40
|
+
# Causes the pool records only when it ended the worker itself: a stop, or a
|
|
41
|
+
# kill it signalled. Nuspace ends workers only by stopping them (directly, or
|
|
42
|
+
# through the pool's close), so these mean the backend let the worker go.
|
|
43
|
+
_LET_GO = frozenset({"stopped", "killed"})
|
|
44
|
+
|
|
37
45
|
|
|
38
46
|
class PoolWorker:
|
|
39
47
|
"""One pool process a plane run holds: its ids and the cell runs placed on it."""
|
|
40
48
|
|
|
41
|
-
__slots__ = ("cells", "
|
|
49
|
+
__slots__ = ("cells", "id", "wid")
|
|
42
50
|
|
|
43
51
|
def __init__(self, worker_id: str, wid: int) -> None:
|
|
44
52
|
self.id = worker_id
|
|
45
53
|
self.wid = wid
|
|
46
54
|
self.cells: set[str] = set()
|
|
47
|
-
self.letting_go = False
|
|
48
|
-
# Why it died by itself, once a cell run on it found out.
|
|
49
|
-
self.gone: str | None = None
|
|
50
55
|
|
|
51
56
|
|
|
52
57
|
class PoolBackend(Backend):
|
|
53
58
|
"""A backend whose workers are ``nustd.mp_pool`` processes. Subclass for placement.
|
|
54
59
|
|
|
55
|
-
Opened inside the pool
|
|
56
|
-
|
|
60
|
+
Opened inside the pool, so it is there to take from and to stop into,
|
|
61
|
+
and closed before it.
|
|
57
62
|
"""
|
|
58
63
|
|
|
59
64
|
def __init__(self) -> None:
|
|
60
65
|
self._pool: WorkerPool | None = None
|
|
61
|
-
self._spares: Spares | None = None
|
|
62
66
|
# Per plane run, its living workers by id.
|
|
63
67
|
self._runs: dict[str, dict[str, PoolWorker]] = {}
|
|
64
68
|
|
|
65
69
|
# --- lifecycle -------------------------------------------------------
|
|
66
70
|
|
|
67
71
|
async def asetup(self, ctx: Context) -> None:
|
|
68
|
-
"""Take the pool
|
|
72
|
+
"""Take the pool."""
|
|
69
73
|
try:
|
|
70
74
|
self._pool = ctx.fabrics.get(WorkerPool)
|
|
71
75
|
except LookupError:
|
|
72
76
|
msg = f"{type(self).__name__} needs a WorkerPool bound around it"
|
|
73
77
|
raise RuntimeError(msg) from None
|
|
74
|
-
self._spares = ctx.fabrics.get(Spares) if ctx.fabrics.has(Spares) else None
|
|
75
78
|
|
|
76
79
|
async def acleanup(self) -> None:
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
for workers in runs.values():
|
|
80
|
-
for worker in workers.values():
|
|
81
|
-
worker.letting_go = True
|
|
82
|
-
if pool is not None:
|
|
83
|
-
pool.kill(worker.wid)
|
|
80
|
+
"""Let go of every worker still held: the pool's close, right after, stops them all at once."""
|
|
81
|
+
self._runs = {}
|
|
84
82
|
|
|
85
83
|
# --- books -----------------------------------------------------------
|
|
86
84
|
|
|
@@ -104,32 +102,48 @@ class PoolBackend(Backend):
|
|
|
104
102
|
return self._pool
|
|
105
103
|
|
|
106
104
|
async def _take(self, run_id: str) -> PoolWorker:
|
|
107
|
-
"""A worker for the run
|
|
108
|
-
|
|
109
|
-
wid = await (self._spares.atake() if self._spares is not None else pool.alaunch())
|
|
105
|
+
"""A worker for the run: a spare when the pool has one, else a cold launch."""
|
|
106
|
+
wid = await self._require_pool().alaunch()
|
|
110
107
|
worker = PoolWorker(mint_ordered_id("w"), wid)
|
|
111
108
|
self._books(run_id)[worker.id] = worker
|
|
112
109
|
return worker
|
|
113
110
|
|
|
114
|
-
async def
|
|
115
|
-
"""A worker gone
|
|
116
|
-
|
|
111
|
+
async def _gone(self, run_id: str, worker: PoolWorker, exc: WorkerGone | None) -> str:
|
|
112
|
+
"""A worker gone: nothing when the pool ended it, else off the books and why.
|
|
113
|
+
|
|
114
|
+
``exc`` is what the request raised, None when the pool no longer keeps
|
|
115
|
+
the worker's record. Its cause and code are None only when the pipe
|
|
116
|
+
closed before the process was reaped; then the exit is awaited,
|
|
117
|
+
bounded by the pool's grace.
|
|
118
|
+
"""
|
|
119
|
+
cause, code = (exc.cause, exc.exitcode) if exc is not None else (None, None)
|
|
120
|
+
if exc is not None and cause is None:
|
|
117
121
|
pool = self._require_pool()
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return
|
|
122
|
+
with contextlib.suppress(UnknownWorker):
|
|
123
|
+
status = await pool.await_exit(worker.wid, pool.grace)
|
|
124
|
+
cause, code = status.cause, status.exitcode
|
|
125
|
+
if cause in _LET_GO:
|
|
126
|
+
return ""
|
|
127
|
+
self._runs.get(run_id, {}).pop(worker.id, None)
|
|
128
|
+
return f"Worker exited: {code}"
|
|
129
|
+
|
|
130
|
+
def _stopping(self, worker: PoolWorker) -> bool:
|
|
131
|
+
"""Whether the pool is ending the worker, or has: a stop or kill under way, or done."""
|
|
132
|
+
with contextlib.suppress(UnknownWorker):
|
|
133
|
+
return self._require_pool().status(worker.wid).state in ("stopping", "exited")
|
|
134
|
+
return False
|
|
125
135
|
|
|
126
136
|
async def _let_go(self, run_id: str, worker: PoolWorker) -> None:
|
|
127
|
-
"""
|
|
128
|
-
|
|
137
|
+
"""Stop a worker on purpose, so the requests it fails report no loss.
|
|
138
|
+
|
|
139
|
+
The pool's ``stop``: the worker tears down within the pool's grace,
|
|
140
|
+
and is killed if it will not. Either way its cause is the pool's own.
|
|
141
|
+
"""
|
|
129
142
|
books = self._runs.get(run_id)
|
|
130
143
|
if books is not None:
|
|
131
144
|
books.pop(worker.id, None)
|
|
132
|
-
|
|
145
|
+
with contextlib.suppress(UnknownWorker):
|
|
146
|
+
await self._require_pool().astop(worker.wid)
|
|
133
147
|
|
|
134
148
|
# --- Backend -----------------------------------------------------------
|
|
135
149
|
|
|
@@ -146,11 +160,16 @@ class PoolBackend(Backend):
|
|
|
146
160
|
raise RuntimeError(msg)
|
|
147
161
|
try:
|
|
148
162
|
await self._require_pool().ateleport(worker.wid, body)
|
|
149
|
-
except
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
except WorkerGone as exc:
|
|
164
|
+
return await self._gone(run_id, worker, exc)
|
|
165
|
+
except UnknownWorker:
|
|
166
|
+
# The pool no longer keeps the worker's record.
|
|
167
|
+
return await self._gone(run_id, worker, None)
|
|
168
|
+
except Interrupted:
|
|
169
|
+
# A stop's SIGINT rung reached a body that would not end politely.
|
|
170
|
+
if self._stopping(worker):
|
|
152
171
|
return ""
|
|
153
|
-
|
|
172
|
+
raise
|
|
154
173
|
return ""
|
|
155
174
|
|
|
156
175
|
async def akill(self, run_id: str) -> list[str]:
|
|
@@ -159,6 +178,6 @@ class PoolBackend(Backend):
|
|
|
159
178
|
if books is None:
|
|
160
179
|
return []
|
|
161
180
|
gone = list(books.values())
|
|
162
|
-
# Shielded: a
|
|
181
|
+
# Shielded: a stop cancelled halfway still ends every process.
|
|
163
182
|
await asyncio.shield(asyncio.gather(*(self._let_go(run_id, w) for w in gone)))
|
|
164
183
|
return [worker.id for worker in gone]
|