Compare commits
97 Commits
0e6940efb1
...
411a5b0f81
| Author | SHA1 | Date |
|---|---|---|
|
|
411a5b0f81 | |
|
|
5f3b65b719 | |
|
|
fc9e0cfb7c | |
|
|
4aedaf3ad3 | |
|
|
e77198bb64 | |
|
|
5b8f6cf4c7 | |
|
|
8868ff19f3 | |
|
|
066011b83d | |
|
|
b1d003d850 | |
|
|
8991ec2bf5 | |
|
|
dfc153c228 | |
|
|
52e8fb43ee | |
|
|
99577b719a | |
|
|
4092db60b2 | |
|
|
4f333dee05 | |
|
|
8a2f74da2c | |
|
|
2bf155131d | |
|
|
0f29f5717a | |
|
|
5ea721683b | |
|
|
f84ef44992 | |
|
|
1e0c57c6c5 | |
|
|
65660c77c7 | |
|
|
c9b415475f | |
|
|
359bcf691f | |
|
|
b3ce5ab4f6 | |
|
|
e89fe03da7 | |
|
|
417b796169 | |
|
|
36cbc07602 | |
|
|
1f2fad22ee | |
|
|
ca5f6f50a8 | |
|
|
a7ff1387c7 | |
|
|
abbb4a79c8 | |
|
|
1529095c32 | |
|
|
8215a7ba34 | |
|
|
c1c4d85958 | |
|
|
88b084802f | |
|
|
bf1dcea9d1 | |
|
|
5c270b89d5 | |
|
|
6ee0149e8d | |
|
|
9c4cd869fb | |
|
|
afd66ce3b7 | |
|
|
f9bdb1b35d | |
|
|
d135ce94af | |
|
|
fb94aa0095 | |
|
|
b71e8575e5 | |
|
|
bbc028e84c | |
|
|
016306adf5 | |
|
|
712c009790 | |
|
|
79396b4a26 | |
|
|
5b2905b702 | |
|
|
776af3fce6 | |
|
|
4639685770 | |
|
|
98a7d69341 | |
|
|
ab6c955949 | |
|
|
a72bb9321e | |
|
|
0e2949ea59 | |
|
|
fb73935dbc | |
|
|
94dfeb1441 | |
|
|
9c1bcb23af | |
|
|
a1ea373f34 | |
|
|
e8f3d64e71 | |
|
|
b30faaca82 | |
|
|
51701fc8dc | |
|
|
7b89204afd | |
|
|
82d02ef404 | |
|
|
b7546fd221 | |
|
|
86c95539ca | |
|
|
706a4b761b | |
|
|
c5af2fa778 | |
|
|
86489cc453 | |
|
|
2631fb4ff3 | |
|
|
aee86f2544 | |
|
|
83c8a8ad78 | |
|
|
daae196048 | |
|
|
70efcb09a0 | |
|
|
a7e74acdff | |
|
|
9c3d3bcec1 | |
|
|
521fb97fe9 | |
|
|
d8a3969048 | |
|
|
01c0db651a | |
|
|
7bcd7aca2b | |
|
|
920d0043b4 | |
|
|
93b9a6cd97 | |
|
|
e7cefba67f | |
|
|
683476cc96 | |
|
|
ad24df0ed7 | |
|
|
a1622c0b94 | |
|
|
a385d20810 | |
|
|
7f9044c1ef | |
|
|
d0618e3cb4 | |
|
|
a5bebf76d5 | |
|
|
814b2e7e62 | |
|
|
1704f73504 | |
|
|
c735fc8544 | |
|
|
c5ea6040bf | |
|
|
d4f2fa547a | |
|
|
20896bfbab |
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Write(.claude/*commit_msg*)",
|
||||||
|
"Write(.claude/git_commit_msg_LATEST.md)",
|
||||||
|
"Bash(date *)",
|
||||||
|
"Bash(cp .claude/*)",
|
||||||
|
"Bash(git diff *)",
|
||||||
|
"Bash(git log *)",
|
||||||
|
"Bash(git status)"
|
||||||
|
],
|
||||||
|
"deny": [],
|
||||||
|
"ask": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
---
|
||||||
|
name: commit-msg
|
||||||
|
description: >
|
||||||
|
Generate git commit messages following project style. Use when user
|
||||||
|
wants to create a commit or asks for a commit message.
|
||||||
|
argument-hint: "[optional-scope-or-description]"
|
||||||
|
disable-model-invocation: true
|
||||||
|
allowed-tools:
|
||||||
|
- Bash(git *)
|
||||||
|
- Bash(date *)
|
||||||
|
- Bash(cp *)
|
||||||
|
- Read
|
||||||
|
- Grep
|
||||||
|
- Glob
|
||||||
|
- Write
|
||||||
|
---
|
||||||
|
|
||||||
|
When generating commit messages, always follow this process:
|
||||||
|
|
||||||
|
0. **Check for staged changes**: if `git diff --staged` is
|
||||||
|
empty, STOP and tell the user "nothing is staged!" with
|
||||||
|
a reminder to `git add` before invoking this skill.
|
||||||
|
|
||||||
|
1. **Gather context** from the staged diff and recent
|
||||||
|
history:
|
||||||
|
|
||||||
|
- Staged changes: !`git diff --staged --stat`
|
||||||
|
- Recent commits: !`git log --oneline -5`
|
||||||
|
|
||||||
|
2. **Analyze the diff**: understand what files changed and
|
||||||
|
the nature of the changes (new feature, bug fix, refactor,
|
||||||
|
etc.)
|
||||||
|
|
||||||
|
3. **Write the commit message** following these rules:
|
||||||
|
|
||||||
|
**Use the accompanying style guide:**
|
||||||
|
- See [style-guide-reference.md](style-guide-reference.md)
|
||||||
|
for detailed analysis of past commits in this repo.
|
||||||
|
|
||||||
|
**Subject Line Format:**
|
||||||
|
- Present tense verbs: Add, Drop, Fix, Use, Move, Adjust, etc.
|
||||||
|
- Target 50 chars (hard max: 67)
|
||||||
|
- Backticks around ALL code elements (classes, functions, modules, vars)
|
||||||
|
- Specific about what changed
|
||||||
|
|
||||||
|
**Body Format (optional - keep simple if warranted):**
|
||||||
|
- Max 67 char line length
|
||||||
|
- Use `-` bullets for lists
|
||||||
|
- Section markers: `Also,` `Deats,` `Other,` `Further,`
|
||||||
|
- Abbreviations: msg, bg, ctx, impl, mod, obvi, tn, fn, bc, var, prolly
|
||||||
|
- Casual yet technically precise tone
|
||||||
|
- Never write lines with only whitespace
|
||||||
|
|
||||||
|
**Common Opening Patterns:**
|
||||||
|
- New features: "Add `feature` to `module`"
|
||||||
|
- Removals: "Drop `attr` from `class`"
|
||||||
|
- Bug fixes: "Fix `issue` in `function`"
|
||||||
|
- Code moves: "Move `thing` to `new_location`"
|
||||||
|
- Adoption: "Use `new_tool` for `task`"
|
||||||
|
- Minor tweaks: "Adjust `behavior` in `component`"
|
||||||
|
|
||||||
|
4. **Write to TWO files**:
|
||||||
|
- `.claude/<timestamp>_<hash>_commit_msg.md`
|
||||||
|
* with `<timestamp>` from `date -u +%Y%m%dT%H%M%SZ` or similar
|
||||||
|
filesystem-safe format.
|
||||||
|
* and `<hash>` from `git log -1 --format=%h` first 7 chars.
|
||||||
|
- `.claude/git_commit_msg_LATEST.md` (overwrite)
|
||||||
|
|
||||||
|
5. **Always include credit footer**:
|
||||||
|
|
||||||
|
When no part of the patch was written by `claude`,
|
||||||
|
```
|
||||||
|
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
|
||||||
|
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||||
|
```
|
||||||
|
|
||||||
|
when some or all of the patch was written by `claude`
|
||||||
|
instead use,
|
||||||
|
|
||||||
|
```
|
||||||
|
(this patch was generated in some part by [`claude-code`][claude-code-gh])
|
||||||
|
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep it concise. Match the tone of recent commits. For simple
|
||||||
|
changes, use subject line only.
|
||||||
|
|
@ -0,0 +1,225 @@
|
||||||
|
# Commit Message Style Guide for `tractor`
|
||||||
|
|
||||||
|
Analysis based on 500 recent commits from the `tractor` repository.
|
||||||
|
|
||||||
|
## Core Principles
|
||||||
|
|
||||||
|
Write commit messages that are technically precise yet casual in
|
||||||
|
tone. Use abbreviations and informal language while maintaining
|
||||||
|
clarity about what changed and why.
|
||||||
|
|
||||||
|
## Subject Line Format
|
||||||
|
|
||||||
|
### Length and Structure
|
||||||
|
- Target: ~50 chars with a hard-max of 67.
|
||||||
|
- Use backticks around code elements (72.2% of commits)
|
||||||
|
- Rarely use colons (5.2%), except for file prefixes
|
||||||
|
- End with '?' for uncertain changes (rare: 0.8%)
|
||||||
|
- End with '!' for important changes (rare: 2.0%)
|
||||||
|
|
||||||
|
### Opening Verbs (Present Tense)
|
||||||
|
|
||||||
|
Most common verbs from analysis:
|
||||||
|
- `Add` (14.4%) - wholly new features/functionality
|
||||||
|
- `Use` (4.4%) - adopt new approach/tool
|
||||||
|
- `Drop` (3.6%) - remove code/feature
|
||||||
|
- `Fix` (2.4%) - bug fixes
|
||||||
|
- `Move`/`Mv` (3.6%) - relocate code
|
||||||
|
- `Adjust` (2.0%) - minor tweaks
|
||||||
|
- `Update` (1.6%) - enhance existing feature
|
||||||
|
- `Bump` (1.2%) - dependency updates
|
||||||
|
- `Rename` (1.2%) - identifier changes
|
||||||
|
- `Set` (1.2%) - configuration changes
|
||||||
|
- `Handle` (1.0%) - add handling logic
|
||||||
|
- `Raise` (1.0%) - add error raising
|
||||||
|
- `Pass` (0.8%) - pass parameters/values
|
||||||
|
- `Support` (0.8%) - add support for something
|
||||||
|
- `Hide` (1.4%) - make private/internal
|
||||||
|
- `Always` (1.4%) - enforce consistent behavior
|
||||||
|
- `Mk` (1.4%) - make/create (abbreviated)
|
||||||
|
- `Start` (1.0%) - begin implementation
|
||||||
|
|
||||||
|
Other frequent verbs: `More`, `Change`, `Extend`, `Disable`, `Log`,
|
||||||
|
`Enable`, `Ensure`, `Expose`, `Allow`
|
||||||
|
|
||||||
|
### Backtick Usage
|
||||||
|
|
||||||
|
Always use backticks for:
|
||||||
|
- Module names: `trio`, `asyncio`, `msgspec`, `greenback`, `stackscope`
|
||||||
|
- Class names: `Context`, `Actor`, `Address`, `PldRx`, `SpawnSpec`
|
||||||
|
- Method names: `.pause_from_sync()`, `._pause()`, `.cancel()`
|
||||||
|
- Function names: `breakpoint()`, `collapse_eg()`, `open_root_actor()`
|
||||||
|
- Decorators: `@acm`, `@context`
|
||||||
|
- Exceptions: `Cancelled`, `TransportClosed`, `MsgTypeError`
|
||||||
|
- Keywords: `finally`, `None`, `False`
|
||||||
|
- Variable names: `tn`, `debug_mode`
|
||||||
|
- Complex expressions: `trio.Cancelled`, `asyncio.Task`
|
||||||
|
|
||||||
|
Most backticked terms in tractor:
|
||||||
|
`trio`, `asyncio`, `Context`, `.pause_from_sync()`, `tn`,
|
||||||
|
`._pause()`, `breakpoint()`, `collapse_eg()`, `Actor`, `@acm`,
|
||||||
|
`.cancel()`, `Cancelled`, `open_root_actor()`, `greenback`
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Good subject lines:
|
||||||
|
```
|
||||||
|
Add `uds` to `._multiaddr`, tweak typing
|
||||||
|
Drop `DebugStatus.shield` attr, add `.req_finished`
|
||||||
|
Use `stackscope` for all actor-tree rendered "views"
|
||||||
|
Fix `.to_asyncio` inter-task-cancellation!
|
||||||
|
Bump `ruff.toml` to target py313
|
||||||
|
Mv `load_module_from_path()` to new `._code_load` submod
|
||||||
|
Always use `tuple`-cast for singleton parent addrs
|
||||||
|
```
|
||||||
|
|
||||||
|
## Body Format
|
||||||
|
|
||||||
|
### General Structure
|
||||||
|
- 43.2% of commits have no body (simple changes)
|
||||||
|
- Use blank line after subject
|
||||||
|
- Max line length: 67 chars
|
||||||
|
- Use `-` bullets for lists (28.0% of commits)
|
||||||
|
- Rarely use `*` bullets (2.4%)
|
||||||
|
|
||||||
|
### Section Markers
|
||||||
|
|
||||||
|
Use these markers to organize longer commit bodies:
|
||||||
|
- `Also,` (most common: 26 occurrences)
|
||||||
|
- `Other,` (13 occurrences)
|
||||||
|
- `Deats,` (11 occurrences) - for implementation details
|
||||||
|
- `Further,` (7 occurrences)
|
||||||
|
- `TODO,` (3 occurrences)
|
||||||
|
- `Impl details,` (2 occurrences)
|
||||||
|
- `Notes,` (1 occurrence)
|
||||||
|
|
||||||
|
### Common Abbreviations
|
||||||
|
|
||||||
|
Use these freely (sorted by frequency):
|
||||||
|
- `msg` (63) - message
|
||||||
|
- `bg` (37) - background
|
||||||
|
- `ctx` (30) - context
|
||||||
|
- `impl` (27) - implementation
|
||||||
|
- `mod` (26) - module
|
||||||
|
- `obvi` (17) - obviously
|
||||||
|
- `tn` (16) - task name
|
||||||
|
- `fn` (15) - function
|
||||||
|
- `vs` (15) - versus
|
||||||
|
- `bc` (14) - because
|
||||||
|
- `var` (14) - variable
|
||||||
|
- `prolly` (9) - probably
|
||||||
|
- `ep` (6) - entry point
|
||||||
|
- `OW` (5) - otherwise
|
||||||
|
- `rn` (4) - right now
|
||||||
|
- `sig` (4) - signal/signature
|
||||||
|
- `deps` (3) - dependencies
|
||||||
|
- `iface` (2) - interface
|
||||||
|
- `subproc` (2) - subprocess
|
||||||
|
- `tho` (2) - though
|
||||||
|
- `ofc` (2) - of course
|
||||||
|
|
||||||
|
### Tone and Style
|
||||||
|
|
||||||
|
- Casual but technical (use `XD` for humor: 23 times)
|
||||||
|
- Use `..` for trailing thoughts (108 occurrences)
|
||||||
|
- Use `Woops,` to acknowledge mistakes (4 subject lines)
|
||||||
|
- Don't be afraid to show personality while being precise
|
||||||
|
|
||||||
|
### Example Bodies
|
||||||
|
|
||||||
|
Simple with bullets:
|
||||||
|
```
|
||||||
|
Add `multiaddr` and bump up some deps
|
||||||
|
|
||||||
|
Since we're planning to use it for (discovery)
|
||||||
|
addressing, allowing replacement of the hacky (pretend)
|
||||||
|
attempt in `tractor._multiaddr` Bp
|
||||||
|
|
||||||
|
Also pin some deps,
|
||||||
|
- make us py312+
|
||||||
|
- use `pdbp` with my frame indexing fix.
|
||||||
|
- mv to latest `xonsh` for fancy cmd/suggestion injections.
|
||||||
|
|
||||||
|
Bump lock file to match obvi!
|
||||||
|
```
|
||||||
|
|
||||||
|
With section markers:
|
||||||
|
```
|
||||||
|
Use `stackscope` for all actor-tree rendered "views"
|
||||||
|
|
||||||
|
Instead of the (much more) limited and hacky `.devx._code`
|
||||||
|
impls, move to using the new `.devx._stackscope` API which
|
||||||
|
wraps the `stackscope` project.
|
||||||
|
|
||||||
|
Deats,
|
||||||
|
- make new `stackscope.extract_stack()` wrapper
|
||||||
|
- port over frame-descing to `_stackscope.pformat_stack()`
|
||||||
|
- move `PdbREPL` to use `stackscope` render approach
|
||||||
|
- update tests for new stack output format
|
||||||
|
|
||||||
|
Also,
|
||||||
|
- tweak log formatting for consistency
|
||||||
|
- add typing hints throughout
|
||||||
|
```
|
||||||
|
|
||||||
|
## Special Patterns
|
||||||
|
|
||||||
|
### WIP Commits
|
||||||
|
Rare (0.2%) - avoid committing WIP if possible
|
||||||
|
|
||||||
|
### Merge Commits
|
||||||
|
Auto-generated (4.4%), don't worry about style
|
||||||
|
|
||||||
|
### File References
|
||||||
|
- Use `module.py` or `.submodule` style
|
||||||
|
- Rarely use `file.py:line` references (0 in analysis)
|
||||||
|
|
||||||
|
### Links
|
||||||
|
- GitHub links used sparingly (3 total)
|
||||||
|
- Prefer code references over external links
|
||||||
|
|
||||||
|
## Footer
|
||||||
|
|
||||||
|
The default footer should credit `claude` (you) for helping generate
|
||||||
|
the commit msg content:
|
||||||
|
|
||||||
|
```
|
||||||
|
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
|
||||||
|
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||||
|
```
|
||||||
|
|
||||||
|
Further, if the patch was solely or in part written
|
||||||
|
by `claude`, instead add:
|
||||||
|
|
||||||
|
```
|
||||||
|
(this patch was generated in some part by [`claude-code`][claude-code-gh])
|
||||||
|
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||||
|
```
|
||||||
|
|
||||||
|
## Summary Checklist
|
||||||
|
|
||||||
|
Before committing, verify:
|
||||||
|
- [ ] Subject line uses present tense verb
|
||||||
|
- [ ] Subject line ~50 chars (hard max 67)
|
||||||
|
- [ ] Code elements wrapped in backticks
|
||||||
|
- [ ] Body lines ≤67 chars
|
||||||
|
- [ ] Abbreviations used where natural
|
||||||
|
- [ ] Casual yet precise tone
|
||||||
|
- [ ] Section markers if body >3 paragraphs
|
||||||
|
- [ ] Technical accuracy maintained
|
||||||
|
|
||||||
|
## Analysis Metadata
|
||||||
|
|
||||||
|
```
|
||||||
|
Source: tractor repository
|
||||||
|
Commits analyzed: 500
|
||||||
|
Date range: 2019-2025
|
||||||
|
Analysis date: 2026-02-08
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(this style guide was generated by [`claude-code`][claude-code-gh]
|
||||||
|
analyzing commit history)
|
||||||
|
|
||||||
|
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||||
|
|
@ -74,24 +74,44 @@ jobs:
|
||||||
# run: mypy tractor/ --ignore-missing-imports --show-traceback
|
# run: mypy tractor/ --ignore-missing-imports --show-traceback
|
||||||
|
|
||||||
|
|
||||||
testing-linux:
|
testing:
|
||||||
name: '${{ matrix.os }} Python ${{ matrix.python }} - ${{ matrix.spawn_backend }}'
|
name: '${{ matrix.os }} Python${{ matrix.python-version }} spawn_backend=${{ matrix.spawn_backend }} tpt_proto=${{ matrix.tpt_proto }}'
|
||||||
timeout-minutes: 10
|
timeout-minutes: 16
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [
|
||||||
python-version: ['3.13']
|
ubuntu-latest,
|
||||||
|
macos-latest,
|
||||||
|
]
|
||||||
|
python-version: [
|
||||||
|
'3.13',
|
||||||
|
# '3.14',
|
||||||
|
]
|
||||||
spawn_backend: [
|
spawn_backend: [
|
||||||
'trio',
|
'trio',
|
||||||
# 'mp_spawn',
|
# 'mp_spawn',
|
||||||
# 'mp_forkserver',
|
# 'mp_forkserver',
|
||||||
|
# ?TODO^ is it worth it to get these running again?
|
||||||
|
#
|
||||||
|
# - [ ] next-gen backends, on 3.13+
|
||||||
|
# https://github.com/goodboy/tractor/issues/379
|
||||||
|
# 'subinterpreter',
|
||||||
|
# 'subint',
|
||||||
]
|
]
|
||||||
|
tpt_proto: [
|
||||||
|
'tcp',
|
||||||
|
'uds',
|
||||||
|
]
|
||||||
|
# https://github.com/orgs/community/discussions/26253#discussioncomment-3250989
|
||||||
|
exclude:
|
||||||
|
# don't do UDS run on macOS (for now)
|
||||||
|
- os: macos-latest
|
||||||
|
tpt_proto: 'uds'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: 'Install uv + py-${{ matrix.python-version }}'
|
- name: 'Install uv + py-${{ matrix.python-version }}'
|
||||||
|
|
@ -118,7 +138,11 @@ jobs:
|
||||||
run: uv tree
|
run: uv tree
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: uv run pytest tests/ --spawn-backend=${{ matrix.spawn_backend }} -rsx
|
run: >
|
||||||
|
uv run
|
||||||
|
pytest tests/ -rsx
|
||||||
|
--spawn-backend=${{ matrix.spawn_backend }}
|
||||||
|
--tpt-proto=${{ matrix.tpt_proto }}
|
||||||
|
|
||||||
# XXX legacy NOTE XXX
|
# XXX legacy NOTE XXX
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -102,3 +102,30 @@ venv.bak/
|
||||||
|
|
||||||
# mypy
|
# mypy
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
|
|
||||||
|
# all files under
|
||||||
|
.git/
|
||||||
|
|
||||||
|
# any commit-msg gen tmp files
|
||||||
|
.claude/*_commit_*.md
|
||||||
|
.claude/*_commit*.toml
|
||||||
|
.claude/*_commit*.txt
|
||||||
|
|
||||||
|
# nix develop --profile .nixdev
|
||||||
|
.nixdev*
|
||||||
|
|
||||||
|
# :Obsession .
|
||||||
|
Session.vim
|
||||||
|
# `gish` local `.md`-files
|
||||||
|
# TODO? better all around automation!
|
||||||
|
# -[ ] it'd be handy to also commit and sync with wtv git service?
|
||||||
|
# -[ ] everything should be put under a `.gish/` no?
|
||||||
|
gitea/
|
||||||
|
gh/
|
||||||
|
|
||||||
|
# ------ macOS ------
|
||||||
|
# Finder metadata
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
|
# LLM conversations that should remain private
|
||||||
|
docs/conversations/
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,4 @@ pkgs.mkShell {
|
||||||
|
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs;
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs;
|
||||||
TMPDIR = "/tmp";
|
TMPDIR = "/tmp";
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
set -e
|
|
||||||
uv venv .venv --python=3.12
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -420,20 +420,17 @@ Check out our experimental system for `guest`_-mode controlled
|
||||||
|
|
||||||
|
|
||||||
async def aio_echo_server(
|
async def aio_echo_server(
|
||||||
to_trio: trio.MemorySendChannel,
|
chan: tractor.to_asyncio.LinkedTaskChannel,
|
||||||
from_trio: asyncio.Queue,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
# a first message must be sent **from** this ``asyncio``
|
# a first message must be sent **from** this ``asyncio``
|
||||||
# task or the ``trio`` side will never unblock from
|
# task or the ``trio`` side will never unblock from
|
||||||
# ``tractor.to_asyncio.open_channel_from():``
|
# ``tractor.to_asyncio.open_channel_from():``
|
||||||
to_trio.send_nowait('start')
|
chan.started_nowait('start')
|
||||||
|
|
||||||
# XXX: this uses an ``from_trio: asyncio.Queue`` currently but we
|
|
||||||
# should probably offer something better.
|
|
||||||
while True:
|
while True:
|
||||||
# echo the msg back
|
# echo the msg back
|
||||||
to_trio.send_nowait(await from_trio.get())
|
chan.send_nowait(await chan.get())
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -445,7 +442,7 @@ Check out our experimental system for `guest`_-mode controlled
|
||||||
# message.
|
# message.
|
||||||
async with tractor.to_asyncio.open_channel_from(
|
async with tractor.to_asyncio.open_channel_from(
|
||||||
aio_echo_server,
|
aio_echo_server,
|
||||||
) as (first, chan):
|
) as (chan, first):
|
||||||
|
|
||||||
assert first == 'start'
|
assert first == 'start'
|
||||||
await ctx.started(first)
|
await ctx.started(first)
|
||||||
|
|
@ -504,8 +501,10 @@ Yes, we spawn a python process, run ``asyncio``, start ``trio`` on the
|
||||||
``asyncio`` loop, then send commands to the ``trio`` scheduled tasks to
|
``asyncio`` loop, then send commands to the ``trio`` scheduled tasks to
|
||||||
tell ``asyncio`` tasks what to do XD
|
tell ``asyncio`` tasks what to do XD
|
||||||
|
|
||||||
We need help refining the `asyncio`-side channel API to be more
|
The ``asyncio``-side task receives a single
|
||||||
`trio`-like. Feel free to sling your opinion in `#273`_!
|
``chan: LinkedTaskChannel`` handle providing a ``trio``-like
|
||||||
|
API: ``.started_nowait()``, ``.send_nowait()``, ``.get()``
|
||||||
|
and more. Feel free to sling your opinion in `#273`_!
|
||||||
|
|
||||||
|
|
||||||
.. _#273: https://github.com/goodboy/tractor/issues/273
|
.. _#273: https://github.com/goodboy/tractor/issues/273
|
||||||
|
|
@ -641,13 +640,15 @@ Help us push toward the future of distributed `Python`.
|
||||||
- Typed capability-based (dialog) protocols ( see `#196
|
- Typed capability-based (dialog) protocols ( see `#196
|
||||||
<https://github.com/goodboy/tractor/issues/196>`_ with draft work
|
<https://github.com/goodboy/tractor/issues/196>`_ with draft work
|
||||||
started in `#311 <https://github.com/goodboy/tractor/pull/311>`_)
|
started in `#311 <https://github.com/goodboy/tractor/pull/311>`_)
|
||||||
- We **recently disabled CI-testing on windows** and need help getting
|
- **macOS is now officially supported** and tested in CI
|
||||||
it running again! (see `#327
|
alongside Linux!
|
||||||
<https://github.com/goodboy/tractor/pull/327>`_). **We do have windows
|
- We **recently disabled CI-testing on windows** and need
|
||||||
support** (and have for quite a while) but since no active hacker
|
help getting it running again! (see `#327
|
||||||
exists in the user-base to help test on that OS, for now we're not
|
<https://github.com/goodboy/tractor/pull/327>`_). **We do
|
||||||
actively maintaining testing due to the added hassle and general
|
have windows support** (and have for quite a while) but
|
||||||
latency..
|
since no active hacker exists in the user-base to help
|
||||||
|
test on that OS, for now we're not actively maintaining
|
||||||
|
testing due to the added hassle and general latency..
|
||||||
|
|
||||||
|
|
||||||
Feel like saying hi?
|
Feel like saying hi?
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,14 @@ async def aio_sleep_forever():
|
||||||
|
|
||||||
|
|
||||||
async def bp_then_error(
|
async def bp_then_error(
|
||||||
to_trio: trio.MemorySendChannel,
|
chan: to_asyncio.LinkedTaskChannel,
|
||||||
from_trio: asyncio.Queue,
|
|
||||||
|
|
||||||
raise_after_bp: bool = True,
|
raise_after_bp: bool = True,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
# sync with `trio`-side (caller) task
|
# sync with `trio`-side (caller) task
|
||||||
to_trio.send_nowait('start')
|
chan.started_nowait('start')
|
||||||
|
|
||||||
# NOTE: what happens here inside the hook needs some refinement..
|
# NOTE: what happens here inside the hook needs some refinement..
|
||||||
# => seems like it's still `.debug._set_trace()` but
|
# => seems like it's still `.debug._set_trace()` but
|
||||||
|
|
@ -60,7 +59,7 @@ async def trio_ctx(
|
||||||
to_asyncio.open_channel_from(
|
to_asyncio.open_channel_from(
|
||||||
bp_then_error,
|
bp_then_error,
|
||||||
# raise_after_bp=not bp_before_started,
|
# raise_after_bp=not bp_before_started,
|
||||||
) as (first, chan),
|
) as (chan, first),
|
||||||
|
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
):
|
):
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ Verify we can dump a `stackscope` tree on a hang.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
|
|
@ -31,13 +32,26 @@ async def main(
|
||||||
from_test: bool = False,
|
from_test: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
|
if platform.system() != 'Darwin':
|
||||||
|
tpt = 'uds'
|
||||||
|
else:
|
||||||
|
# XXX, precisely we can't use pytest's tmp-path generation
|
||||||
|
# for tests.. apparently because:
|
||||||
|
#
|
||||||
|
# > The OSError: AF_UNIX path too long in macOS Python occurs
|
||||||
|
# > because the path to the Unix domain socket exceeds the
|
||||||
|
# > operating system's maximum path length limit (around 104
|
||||||
|
#
|
||||||
|
# WHICH IS just, wtf hillarious XD
|
||||||
|
tpt = 'tcp'
|
||||||
|
|
||||||
async with (
|
async with (
|
||||||
tractor.open_nursery(
|
tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
enable_stack_on_sig=True,
|
enable_stack_on_sig=True,
|
||||||
# maybe_enable_greenback=False,
|
# maybe_enable_greenback=False,
|
||||||
loglevel='devx',
|
loglevel='devx',
|
||||||
enable_transports=['uds'],
|
enable_transports=[tpt],
|
||||||
) as an,
|
) as an,
|
||||||
):
|
):
|
||||||
ptl: tractor.Portal = await an.start_actor(
|
ptl: tractor.Portal = await an.start_actor(
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import platform
|
||||||
|
|
||||||
import tractor
|
import tractor
|
||||||
import trio
|
import trio
|
||||||
|
|
||||||
|
|
@ -34,9 +36,22 @@ async def just_bp(
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
||||||
|
if platform.system() != 'Darwin':
|
||||||
|
tpt = 'uds'
|
||||||
|
else:
|
||||||
|
# XXX, precisely we can't use pytest's tmp-path generation
|
||||||
|
# for tests.. apparently because:
|
||||||
|
#
|
||||||
|
# > The OSError: AF_UNIX path too long in macOS Python occurs
|
||||||
|
# > because the path to the Unix domain socket exceeds the
|
||||||
|
# > operating system's maximum path length limit (around 104
|
||||||
|
#
|
||||||
|
# WHICH IS just, wtf hillarious XD
|
||||||
|
tpt = 'tcp'
|
||||||
|
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
enable_transports=['uds'],
|
enable_transports=[tpt],
|
||||||
loglevel='devx',
|
loglevel='devx',
|
||||||
) as n:
|
) as n:
|
||||||
p = await n.start_actor(
|
p = await n.start_actor(
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ async def main() -> list[int]:
|
||||||
# yes, a nursery which spawns `trio`-"actors" B)
|
# yes, a nursery which spawns `trio`-"actors" B)
|
||||||
an: ActorNursery
|
an: ActorNursery
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
loglevel='cancel',
|
loglevel='error',
|
||||||
# debug_mode=True,
|
# debug_mode=True,
|
||||||
) as an:
|
) as an:
|
||||||
|
|
||||||
|
|
@ -118,8 +118,10 @@ async def main() -> list[int]:
|
||||||
cancelled: bool = await portal.cancel_actor()
|
cancelled: bool = await portal.cancel_actor()
|
||||||
assert cancelled
|
assert cancelled
|
||||||
|
|
||||||
print(f"STREAM TIME = {time.time() - start}")
|
print(
|
||||||
print(f"STREAM + SPAWN TIME = {time.time() - pre_start}")
|
f"STREAM TIME = {time.time() - start}\n"
|
||||||
|
f"STREAM + SPAWN TIME = {time.time() - pre_start}\n"
|
||||||
|
)
|
||||||
assert result_stream == list(range(seed))
|
assert result_stream == list(range(seed))
|
||||||
return result_stream
|
return result_stream
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,21 +11,17 @@ import tractor
|
||||||
|
|
||||||
|
|
||||||
async def aio_echo_server(
|
async def aio_echo_server(
|
||||||
to_trio: trio.MemorySendChannel,
|
chan: tractor.to_asyncio.LinkedTaskChannel,
|
||||||
from_trio: asyncio.Queue,
|
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
# a first message must be sent **from** this ``asyncio``
|
# a first message must be sent **from** this ``asyncio``
|
||||||
# task or the ``trio`` side will never unblock from
|
# task or the ``trio`` side will never unblock from
|
||||||
# ``tractor.to_asyncio.open_channel_from():``
|
# ``tractor.to_asyncio.open_channel_from():``
|
||||||
to_trio.send_nowait('start')
|
chan.started_nowait('start')
|
||||||
|
|
||||||
# XXX: this uses an ``from_trio: asyncio.Queue`` currently but we
|
|
||||||
# should probably offer something better.
|
|
||||||
while True:
|
while True:
|
||||||
# echo the msg back
|
# echo the msg back
|
||||||
to_trio.send_nowait(await from_trio.get())
|
chan.send_nowait(await chan.get())
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,7 +33,7 @@ async def trio_to_aio_echo_server(
|
||||||
# message.
|
# message.
|
||||||
async with tractor.to_asyncio.open_channel_from(
|
async with tractor.to_asyncio.open_channel_from(
|
||||||
aio_echo_server,
|
aio_echo_server,
|
||||||
) as (first, chan):
|
) as (chan, first):
|
||||||
|
|
||||||
assert first == 'start'
|
assert first == 'start'
|
||||||
await ctx.started(first)
|
await ctx.started(first)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ name = "tractor"
|
||||||
version = "0.1.0a6dev0"
|
version = "0.1.0a6dev0"
|
||||||
description = 'structured concurrent `trio`-"actors"'
|
description = 'structured concurrent `trio`-"actors"'
|
||||||
authors = [{ name = "Tyler Goodlet", email = "goodboy_foss@protonmail.com" }]
|
authors = [{ name = "Tyler Goodlet", email = "goodboy_foss@protonmail.com" }]
|
||||||
requires-python = ">= 3.11"
|
requires-python = ">=3.12, <3.14"
|
||||||
readme = "docs/README.rst"
|
readme = "docs/README.rst"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
keywords = [
|
keywords = [
|
||||||
|
|
@ -24,11 +24,13 @@ keywords = [
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
"Operating System :: POSIX :: Linux",
|
"Operating System :: POSIX :: Linux",
|
||||||
|
"Operating System :: MacOS",
|
||||||
"Framework :: Trio",
|
"Framework :: Trio",
|
||||||
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
"Programming Language :: Python :: 3 :: Only",
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: Python :: 3.13",
|
||||||
"Topic :: System :: Distributed Computing",
|
"Topic :: System :: Distributed Computing",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
@ -42,11 +44,12 @@ dependencies = [
|
||||||
"wrapt>=1.16.0,<2",
|
"wrapt>=1.16.0,<2",
|
||||||
"colorlog>=6.8.2,<7",
|
"colorlog>=6.8.2,<7",
|
||||||
# built-in multi-actor `pdb` REPL
|
# built-in multi-actor `pdb` REPL
|
||||||
"pdbp>=1.6,<2", # windows only (from `pdbp`)
|
"pdbp>=1.8.2,<2", # windows only (from `pdbp`)
|
||||||
# typed IPC msging
|
# typed IPC msging
|
||||||
"msgspec>=0.19.0",
|
"msgspec>=0.19.0",
|
||||||
"cffi>=1.17.1",
|
"cffi>=1.17.1",
|
||||||
"bidict>=0.23.1",
|
"bidict>=0.23.1",
|
||||||
|
"platformdirs>=4.4.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
# ------ project ------
|
# ------ project ------
|
||||||
|
|
@ -74,7 +77,7 @@ testing = [
|
||||||
repl = [
|
repl = [
|
||||||
"pyperclip>=1.9.0",
|
"pyperclip>=1.9.0",
|
||||||
"prompt-toolkit>=3.0.50",
|
"prompt-toolkit>=3.0.50",
|
||||||
"xonsh>=0.19.2",
|
"xonsh>=0.22.2",
|
||||||
"psutil>=7.0.0",
|
"psutil>=7.0.0",
|
||||||
]
|
]
|
||||||
lint = [
|
lint = [
|
||||||
|
|
@ -86,15 +89,19 @@ lint = [
|
||||||
# "sphinx>="
|
# "sphinx>="
|
||||||
# "sphinx_book_theme>="
|
# "sphinx_book_theme>="
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
# ------ dependency-groups ------
|
# ------ dependency-groups ------
|
||||||
|
|
||||||
# ------ dependency-groups ------
|
|
||||||
|
|
||||||
[tool.uv.sources]
|
[tool.uv.sources]
|
||||||
# XXX NOTE, only for @goodboy's hacking on `pprint(sort_dicts=False)`
|
# XXX NOTE, only for @goodboy's hacking on `pprint(sort_dicts=False)`
|
||||||
# for the `pp` alias..
|
# for the `pp` alias..
|
||||||
# pdbp = { path = "../pdbp", editable = true }
|
|
||||||
|
# [tool.uv.sources.pdbp]
|
||||||
|
# XXX, in case we need to tmp patch again.
|
||||||
|
# git = "https://github.com/goodboy/pdbp.git"
|
||||||
|
# branch ="repair_stack_trace_frame_indexing"
|
||||||
|
# path = "../pdbp"
|
||||||
|
# editable = true
|
||||||
|
|
||||||
# ------ tool.uv.sources ------
|
# ------ tool.uv.sources ------
|
||||||
# TODO, distributed (multi-host) extensions
|
# TODO, distributed (multi-host) extensions
|
||||||
|
|
@ -156,6 +163,7 @@ all_bullets = true
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
minversion = '6.0'
|
minversion = '6.0'
|
||||||
|
# https://docs.pytest.org/en/stable/reference/reference.html#configuration-options
|
||||||
testpaths = [
|
testpaths = [
|
||||||
'tests'
|
'tests'
|
||||||
]
|
]
|
||||||
|
|
@ -166,10 +174,17 @@ addopts = [
|
||||||
'--import-mode=importlib',
|
'--import-mode=importlib',
|
||||||
# don't show frickin captured logs AGAIN in the report..
|
# don't show frickin captured logs AGAIN in the report..
|
||||||
'--show-capture=no',
|
'--show-capture=no',
|
||||||
|
|
||||||
|
# disable `xonsh` plugin
|
||||||
|
# https://docs.pytest.org/en/stable/how-to/plugins.html#disabling-plugins-from-autoloading
|
||||||
|
# https://docs.pytest.org/en/stable/how-to/plugins.html#deactivating-unregistering-a-plugin-by-name
|
||||||
|
'-p no:xonsh'
|
||||||
]
|
]
|
||||||
log_cli = false
|
log_cli = false
|
||||||
# TODO: maybe some of these layout choices?
|
# TODO: maybe some of these layout choices?
|
||||||
# https://docs.pytest.org/en/8.0.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules
|
# https://docs.pytest.org/en/8.0.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules
|
||||||
# pythonpath = "src"
|
# pythonpath = "src"
|
||||||
|
|
||||||
|
# https://docs.pytest.org/en/stable/reference/reference.html#confval-console_output_style
|
||||||
|
console_output_style = 'progress'
|
||||||
# ------ tool.pytest ------
|
# ------ tool.pytest ------
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
# vim: ft=ini
|
|
||||||
# pytest.ini for tractor
|
|
||||||
|
|
||||||
[pytest]
|
|
||||||
# don't show frickin captured logs AGAIN in the report..
|
|
||||||
addopts = --show-capture='no'
|
|
||||||
log_cli = false
|
|
||||||
; minversion = 6.0
|
|
||||||
|
|
@ -35,8 +35,8 @@ exclude = [
|
||||||
line-length = 88
|
line-length = 88
|
||||||
indent-width = 4
|
indent-width = 4
|
||||||
|
|
||||||
# Assume Python 3.9
|
# assume latest minor cpython
|
||||||
target-version = "py311"
|
target-version = "py313"
|
||||||
|
|
||||||
[lint]
|
[lint]
|
||||||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import platform
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import tractor
|
||||||
from tractor._testing import (
|
from tractor._testing import (
|
||||||
examples_dir as examples_dir,
|
examples_dir as examples_dir,
|
||||||
tractor_test as tractor_test,
|
tractor_test as tractor_test,
|
||||||
|
|
@ -22,6 +23,8 @@ pytest_plugins: list[str] = [
|
||||||
'tractor._testing.pytest',
|
'tractor._testing.pytest',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
_ci_env: bool = os.environ.get('CI', False)
|
||||||
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
|
|
||||||
# Sending signal.SIGINT on subprocess fails on windows. Use CTRL_* alternatives
|
# Sending signal.SIGINT on subprocess fails on windows. Use CTRL_* alternatives
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
|
|
@ -34,9 +37,8 @@ else:
|
||||||
_INT_SIGNAL = signal.SIGINT
|
_INT_SIGNAL = signal.SIGINT
|
||||||
_INT_RETURN_CODE = 1 if sys.version_info < (3, 8) else -signal.SIGINT.value
|
_INT_RETURN_CODE = 1 if sys.version_info < (3, 8) else -signal.SIGINT.value
|
||||||
_PROC_SPAWN_WAIT = (
|
_PROC_SPAWN_WAIT = (
|
||||||
0.6
|
2 if _ci_env
|
||||||
if sys.version_info < (3, 7)
|
else 1
|
||||||
else 0.4
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,6 +46,10 @@ no_windows = pytest.mark.skipif(
|
||||||
platform.system() == "Windows",
|
platform.system() == "Windows",
|
||||||
reason="Test is unsupported on windows",
|
reason="Test is unsupported on windows",
|
||||||
)
|
)
|
||||||
|
no_macos = pytest.mark.skipif(
|
||||||
|
platform.system() == "Darwin",
|
||||||
|
reason="Test is unsupported on MacOS",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(
|
def pytest_addoption(
|
||||||
|
|
@ -61,7 +67,7 @@ def pytest_addoption(
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session', autouse=True)
|
@pytest.fixture(scope='session', autouse=True)
|
||||||
def loglevel(request):
|
def loglevel(request) -> str:
|
||||||
import tractor
|
import tractor
|
||||||
orig = tractor.log._default_loglevel
|
orig = tractor.log._default_loglevel
|
||||||
level = tractor.log._default_loglevel = request.config.option.loglevel
|
level = tractor.log._default_loglevel = request.config.option.loglevel
|
||||||
|
|
@ -69,12 +75,44 @@ def loglevel(request):
|
||||||
level=level,
|
level=level,
|
||||||
name='tractor', # <- enable root logger
|
name='tractor', # <- enable root logger
|
||||||
)
|
)
|
||||||
log.info(f'Test-harness logging level: {level}\n')
|
log.info(
|
||||||
|
f'Test-harness set runtime loglevel: {level!r}\n'
|
||||||
|
)
|
||||||
yield level
|
yield level
|
||||||
tractor.log._default_loglevel = orig
|
tractor.log._default_loglevel = orig
|
||||||
|
|
||||||
|
|
||||||
_ci_env: bool = os.environ.get('CI', False)
|
@pytest.fixture(scope='function')
|
||||||
|
def test_log(
|
||||||
|
request,
|
||||||
|
loglevel: str,
|
||||||
|
) -> tractor.log.StackLevelAdapter:
|
||||||
|
'''
|
||||||
|
Deliver a per test-module-fn logger instance for reporting from
|
||||||
|
within actual test bodies/fixtures.
|
||||||
|
|
||||||
|
For example this can be handy to report certain error cases from
|
||||||
|
exception handlers using `test_log.exception()`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
modname: str = request.function.__module__
|
||||||
|
log = tractor.log.get_logger(
|
||||||
|
name=modname, # <- enable root logger
|
||||||
|
# pkg_name='tests',
|
||||||
|
)
|
||||||
|
_log = tractor.log.get_console_log(
|
||||||
|
level=loglevel,
|
||||||
|
logger=log,
|
||||||
|
name=modname,
|
||||||
|
# pkg_name='tests',
|
||||||
|
)
|
||||||
|
_log.debug(
|
||||||
|
f'In-test-logging requested\n'
|
||||||
|
f'test_log.name: {log.name!r}\n'
|
||||||
|
f'level: {loglevel!r}\n'
|
||||||
|
|
||||||
|
)
|
||||||
|
yield _log
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
|
|
@ -110,6 +148,8 @@ def daemon(
|
||||||
testdir: pytest.Pytester,
|
testdir: pytest.Pytester,
|
||||||
reg_addr: tuple[str, int],
|
reg_addr: tuple[str, int],
|
||||||
tpt_proto: str,
|
tpt_proto: str,
|
||||||
|
ci_env: bool,
|
||||||
|
test_log: tractor.log.StackLevelAdapter,
|
||||||
|
|
||||||
) -> subprocess.Popen:
|
) -> subprocess.Popen:
|
||||||
'''
|
'''
|
||||||
|
|
@ -125,10 +165,12 @@ def daemon(
|
||||||
"import tractor; "
|
"import tractor; "
|
||||||
"tractor.run_daemon([], "
|
"tractor.run_daemon([], "
|
||||||
"registry_addrs={reg_addrs}, "
|
"registry_addrs={reg_addrs}, "
|
||||||
|
"enable_transports={enable_tpts}, "
|
||||||
"debug_mode={debug_mode}, "
|
"debug_mode={debug_mode}, "
|
||||||
"loglevel={ll})"
|
"loglevel={ll})"
|
||||||
).format(
|
).format(
|
||||||
reg_addrs=str([reg_addr]),
|
reg_addrs=str([reg_addr]),
|
||||||
|
enable_tpts=str([tpt_proto]),
|
||||||
ll="'{}'".format(loglevel) if loglevel else None,
|
ll="'{}'".format(loglevel) if loglevel else None,
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
)
|
)
|
||||||
|
|
@ -147,13 +189,25 @@ def daemon(
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO! we should poll for the registry socket-bind to take place
|
||||||
|
# and only once that's done yield to the requester!
|
||||||
|
# -[ ] TCP: use the `._root.open_root_actor()`::`ping_tpt_socket()`
|
||||||
|
# closure!
|
||||||
|
# -[ ] UDS: can we do something similar for 'pinging" the
|
||||||
|
# file-socket?
|
||||||
|
#
|
||||||
|
global _PROC_SPAWN_WAIT
|
||||||
# UDS sockets are **really** fast to bind()/listen()/connect()
|
# UDS sockets are **really** fast to bind()/listen()/connect()
|
||||||
# so it's often required that we delay a bit more starting
|
# so it's often required that we delay a bit more starting
|
||||||
# the first actor-tree..
|
# the first actor-tree..
|
||||||
if tpt_proto == 'uds':
|
if tpt_proto == 'uds':
|
||||||
global _PROC_SPAWN_WAIT
|
_PROC_SPAWN_WAIT += 1.6
|
||||||
_PROC_SPAWN_WAIT = 0.6
|
|
||||||
|
|
||||||
|
if _non_linux and ci_env:
|
||||||
|
_PROC_SPAWN_WAIT += 1
|
||||||
|
|
||||||
|
# XXX, allow time for the sub-py-proc to boot up.
|
||||||
|
# !TODO, see ping-polling ideas above!
|
||||||
time.sleep(_PROC_SPAWN_WAIT)
|
time.sleep(_PROC_SPAWN_WAIT)
|
||||||
|
|
||||||
assert not proc.returncode
|
assert not proc.returncode
|
||||||
|
|
@ -163,18 +217,30 @@ def daemon(
|
||||||
# XXX! yeah.. just be reaaal careful with this bc sometimes it
|
# XXX! yeah.. just be reaaal careful with this bc sometimes it
|
||||||
# can lock up on the `_io.BufferedReader` and hang..
|
# can lock up on the `_io.BufferedReader` and hang..
|
||||||
stderr: str = proc.stderr.read().decode()
|
stderr: str = proc.stderr.read().decode()
|
||||||
if stderr:
|
stdout: str = proc.stdout.read().decode()
|
||||||
|
if (
|
||||||
|
stderr
|
||||||
|
or
|
||||||
|
stdout
|
||||||
|
):
|
||||||
print(
|
print(
|
||||||
f'Daemon actor tree produced STDERR:\n'
|
f'Daemon actor tree produced output:\n'
|
||||||
f'{proc.args}\n'
|
f'{proc.args}\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
f'{stderr}\n'
|
f'stderr: {stderr!r}\n'
|
||||||
|
f'stdout: {stdout!r}\n'
|
||||||
)
|
)
|
||||||
if proc.returncode != -2:
|
|
||||||
raise RuntimeError(
|
if (rc := proc.returncode) != -2:
|
||||||
'Daemon actor tree failed !?\n'
|
msg: str = (
|
||||||
f'{proc.args}\n'
|
f'Daemon actor tree was not cancelled !?\n'
|
||||||
|
f'proc.args: {proc.args!r}\n'
|
||||||
|
f'proc.returncode: {rc!r}\n'
|
||||||
)
|
)
|
||||||
|
if rc < 0:
|
||||||
|
raise RuntimeError(msg)
|
||||||
|
|
||||||
|
test_log.error(msg)
|
||||||
|
|
||||||
|
|
||||||
# @pytest.fixture(autouse=True)
|
# @pytest.fixture(autouse=True)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import time
|
import platform
|
||||||
import signal
|
import signal
|
||||||
|
import time
|
||||||
from typing import (
|
from typing import (
|
||||||
Callable,
|
Callable,
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
|
|
@ -33,6 +34,17 @@ if TYPE_CHECKING:
|
||||||
from pexpect import pty_spawn
|
from pexpect import pty_spawn
|
||||||
|
|
||||||
|
|
||||||
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
# register custom marks to avoid warnings see,
|
||||||
|
# https://docs.pytest.org/en/stable/how-to/writing_plugins.html#registering-custom-markers
|
||||||
|
config.addinivalue_line(
|
||||||
|
'markers',
|
||||||
|
'ctlcs_bish: test will (likely) not behave under SIGINT..'
|
||||||
|
)
|
||||||
|
|
||||||
# a fn that sub-instantiates a `pexpect.spawn()`
|
# a fn that sub-instantiates a `pexpect.spawn()`
|
||||||
# and returns it.
|
# and returns it.
|
||||||
type PexpectSpawner = Callable[
|
type PexpectSpawner = Callable[
|
||||||
|
|
@ -68,12 +80,16 @@ def spawn(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
|
# disable colored tbs
|
||||||
os.environ['PYTHON_COLORS'] = '0'
|
os.environ['PYTHON_COLORS'] = '0'
|
||||||
|
# disable all ANSI color output
|
||||||
|
# os.environ['NO_COLOR'] = '1'
|
||||||
|
|
||||||
spawned: PexpectSpawner|None = None
|
spawned: PexpectSpawner|None = None
|
||||||
|
|
||||||
def _spawn(
|
def _spawn(
|
||||||
cmd: str,
|
cmd: str,
|
||||||
|
expect_timeout: float = 4,
|
||||||
**mkcmd_kwargs,
|
**mkcmd_kwargs,
|
||||||
) -> pty_spawn.spawn:
|
) -> pty_spawn.spawn:
|
||||||
nonlocal spawned
|
nonlocal spawned
|
||||||
|
|
@ -83,11 +99,17 @@ def spawn(
|
||||||
cmd,
|
cmd,
|
||||||
**mkcmd_kwargs,
|
**mkcmd_kwargs,
|
||||||
),
|
),
|
||||||
expect_timeout=3,
|
expect_timeout=(timeout:=(
|
||||||
|
expect_timeout + 6
|
||||||
|
if _non_linux and _ci_env
|
||||||
|
else expect_timeout
|
||||||
|
)),
|
||||||
# preexec_fn=unset_colors,
|
# preexec_fn=unset_colors,
|
||||||
# ^TODO? get `pytest` core to expose underlying
|
# ^TODO? get `pytest` core to expose underlying
|
||||||
# `pexpect.spawn()` stuff?
|
# `pexpect.spawn()` stuff?
|
||||||
)
|
)
|
||||||
|
# sanity
|
||||||
|
assert spawned.timeout == timeout
|
||||||
return spawned
|
return spawned
|
||||||
|
|
||||||
# such that test-dep can pass input script name.
|
# such that test-dep can pass input script name.
|
||||||
|
|
@ -146,6 +168,8 @@ def ctlc(
|
||||||
mark.name == 'ctlcs_bish'
|
mark.name == 'ctlcs_bish'
|
||||||
and
|
and
|
||||||
use_ctlc
|
use_ctlc
|
||||||
|
and
|
||||||
|
all(mark.args)
|
||||||
):
|
):
|
||||||
pytest.skip(
|
pytest.skip(
|
||||||
f'Test {node} prolly uses something from the stdlib (namely `asyncio`..)\n'
|
f'Test {node} prolly uses something from the stdlib (namely `asyncio`..)\n'
|
||||||
|
|
@ -251,12 +275,13 @@ def assert_before(
|
||||||
err_on_false=True,
|
err_on_false=True,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
return str(child.before.decode())
|
||||||
|
|
||||||
|
|
||||||
def do_ctlc(
|
def do_ctlc(
|
||||||
child,
|
child,
|
||||||
count: int = 3,
|
count: int = 3,
|
||||||
delay: float = 0.1,
|
delay: float|None = None,
|
||||||
patt: str|None = None,
|
patt: str|None = None,
|
||||||
|
|
||||||
# expect repl UX to reprint the prompt after every
|
# expect repl UX to reprint the prompt after every
|
||||||
|
|
@ -268,6 +293,7 @@ def do_ctlc(
|
||||||
) -> str|None:
|
) -> str|None:
|
||||||
|
|
||||||
before: str|None = None
|
before: str|None = None
|
||||||
|
delay = delay or 0.1
|
||||||
|
|
||||||
# make sure ctl-c sends don't do anything but repeat output
|
# make sure ctl-c sends don't do anything but repeat output
|
||||||
for _ in range(count):
|
for _ in range(count):
|
||||||
|
|
@ -278,7 +304,10 @@ def do_ctlc(
|
||||||
# if you run this test manually it works just fine..
|
# if you run this test manually it works just fine..
|
||||||
if expect_prompt:
|
if expect_prompt:
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
child.expect(PROMPT)
|
child.expect(
|
||||||
|
PROMPT,
|
||||||
|
timeout=(child.timeout * 2) if _ci_env else child.timeout,
|
||||||
|
)
|
||||||
before = str(child.before.decode())
|
before = str(child.before.decode())
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ from .conftest import (
|
||||||
in_prompt_msg,
|
in_prompt_msg,
|
||||||
assert_before,
|
assert_before,
|
||||||
)
|
)
|
||||||
|
from ..conftest import (
|
||||||
|
_ci_env,
|
||||||
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..conftest import PexpectSpawner
|
from ..conftest import PexpectSpawner
|
||||||
|
|
@ -51,13 +54,14 @@ if TYPE_CHECKING:
|
||||||
# - recurrent root errors
|
# - recurrent root errors
|
||||||
|
|
||||||
|
|
||||||
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
|
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
pytest.skip(
|
pytest.skip(
|
||||||
'Debugger tests have no windows support (yet)',
|
'Debugger tests have no windows support (yet)',
|
||||||
allow_module_level=True,
|
allow_module_level=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO: was trying to this xfail style but some weird bug i see in CI
|
# TODO: was trying to this xfail style but some weird bug i see in CI
|
||||||
# that's happening at collect time.. pretty soon gonna dump actions i'm
|
# that's happening at collect time.. pretty soon gonna dump actions i'm
|
||||||
# thinkin...
|
# thinkin...
|
||||||
|
|
@ -193,6 +197,11 @@ def test_root_actor_bp_forever(
|
||||||
child.expect(EOF)
|
child.expect(EOF)
|
||||||
|
|
||||||
|
|
||||||
|
# skip on non-Linux CI
|
||||||
|
@pytest.mark.ctlcs_bish(
|
||||||
|
_non_linux,
|
||||||
|
_ci_env,
|
||||||
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'do_next',
|
'do_next',
|
||||||
(True, False),
|
(True, False),
|
||||||
|
|
@ -258,6 +267,11 @@ def test_subactor_error(
|
||||||
child.expect(EOF)
|
child.expect(EOF)
|
||||||
|
|
||||||
|
|
||||||
|
# skip on non-Linux CI
|
||||||
|
@pytest.mark.ctlcs_bish(
|
||||||
|
_non_linux,
|
||||||
|
_ci_env,
|
||||||
|
)
|
||||||
def test_subactor_breakpoint(
|
def test_subactor_breakpoint(
|
||||||
spawn,
|
spawn,
|
||||||
ctlc: bool,
|
ctlc: bool,
|
||||||
|
|
@ -480,8 +494,24 @@ def test_multi_daemon_subactors(
|
||||||
stream.
|
stream.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
child = spawn('multi_daemon_subactors')
|
non_linux = _non_linux
|
||||||
|
if non_linux and ctlc:
|
||||||
|
pytest.skip(
|
||||||
|
'Ctl-c + MacOS is too unreliable/racy for this test..\n'
|
||||||
|
)
|
||||||
|
# !TODO, if someone with more patience then i wants to muck
|
||||||
|
# with the timings on this please feel free to see all the
|
||||||
|
# `non_linux` branching logic i added on my first attempt
|
||||||
|
# below!
|
||||||
|
#
|
||||||
|
# my conclusion was that if i were to run the script
|
||||||
|
# manually, and thus as slowly as a human would, the test
|
||||||
|
# would and should pass as described in this test fn, however
|
||||||
|
# after fighting with it for >= 1hr. i decided more then
|
||||||
|
# likely the more extensive `linux` testing should cover most
|
||||||
|
# regressions.
|
||||||
|
|
||||||
|
child = spawn('multi_daemon_subactors')
|
||||||
child.expect(PROMPT)
|
child.expect(PROMPT)
|
||||||
|
|
||||||
# there can be a race for which subactor will acquire
|
# there can be a race for which subactor will acquire
|
||||||
|
|
@ -511,8 +541,19 @@ def test_multi_daemon_subactors(
|
||||||
else:
|
else:
|
||||||
raise ValueError('Neither log msg was found !?')
|
raise ValueError('Neither log msg was found !?')
|
||||||
|
|
||||||
|
non_linux_delay: float = 0.3
|
||||||
if ctlc:
|
if ctlc:
|
||||||
do_ctlc(child)
|
do_ctlc(
|
||||||
|
child,
|
||||||
|
delay=(
|
||||||
|
non_linux_delay
|
||||||
|
if non_linux
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if non_linux:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# NOTE: previously since we did not have clobber prevention
|
# NOTE: previously since we did not have clobber prevention
|
||||||
# in the root actor this final resume could result in the debugger
|
# in the root actor this final resume could result in the debugger
|
||||||
|
|
@ -543,33 +584,66 @@ def test_multi_daemon_subactors(
|
||||||
# assert "in use by child ('bp_forever'," in before
|
# assert "in use by child ('bp_forever'," in before
|
||||||
|
|
||||||
if ctlc:
|
if ctlc:
|
||||||
do_ctlc(child)
|
do_ctlc(
|
||||||
|
child,
|
||||||
|
delay=(
|
||||||
|
non_linux_delay
|
||||||
|
if non_linux
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if non_linux:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# expect another breakpoint actor entry
|
# expect another breakpoint actor entry
|
||||||
child.sendline('c')
|
child.sendline('c')
|
||||||
child.expect(PROMPT)
|
child.expect(PROMPT)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
assert_before(
|
before: str = assert_before(
|
||||||
child,
|
child,
|
||||||
bp_forev_parts,
|
bp_forev_parts,
|
||||||
)
|
)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
assert_before(
|
before: str = assert_before(
|
||||||
child,
|
child,
|
||||||
name_error_parts,
|
name_error_parts,
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if ctlc:
|
if ctlc:
|
||||||
do_ctlc(child)
|
before: str = do_ctlc(
|
||||||
|
child,
|
||||||
|
delay=(
|
||||||
|
non_linux_delay
|
||||||
|
if non_linux
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if non_linux:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# should crash with the 2nd name error (simulates
|
# should crash with the 2nd name error (simulates
|
||||||
# a retry) and then the root eventually (boxed) errors
|
# a retry) and then the root eventually (boxed) errors
|
||||||
# after 1 or more further bp actor entries.
|
# after 1 or more further bp actor entries.
|
||||||
|
|
||||||
child.sendline('c')
|
child.sendline('c')
|
||||||
child.expect(PROMPT)
|
try:
|
||||||
|
child.expect(
|
||||||
|
PROMPT,
|
||||||
|
timeout=3,
|
||||||
|
)
|
||||||
|
except EOF:
|
||||||
|
before: str = child.before.decode()
|
||||||
|
print(
|
||||||
|
f'\n'
|
||||||
|
f'??? NEVER RXED `pdb` PROMPT ???\n'
|
||||||
|
f'\n'
|
||||||
|
f'{before}\n'
|
||||||
|
)
|
||||||
|
raise
|
||||||
|
|
||||||
assert_before(
|
assert_before(
|
||||||
child,
|
child,
|
||||||
name_error_parts,
|
name_error_parts,
|
||||||
|
|
@ -689,7 +763,8 @@ def test_multi_subactors_root_errors(
|
||||||
|
|
||||||
@has_nested_actors
|
@has_nested_actors
|
||||||
def test_multi_nested_subactors_error_through_nurseries(
|
def test_multi_nested_subactors_error_through_nurseries(
|
||||||
spawn,
|
ci_env: bool,
|
||||||
|
spawn: PexpectSpawner,
|
||||||
|
|
||||||
# TODO: address debugger issue for nested tree:
|
# TODO: address debugger issue for nested tree:
|
||||||
# https://github.com/goodboy/tractor/issues/320
|
# https://github.com/goodboy/tractor/issues/320
|
||||||
|
|
@ -712,7 +787,16 @@ def test_multi_nested_subactors_error_through_nurseries(
|
||||||
|
|
||||||
for send_char in itertools.cycle(['c', 'q']):
|
for send_char in itertools.cycle(['c', 'q']):
|
||||||
try:
|
try:
|
||||||
child.expect(PROMPT)
|
child.expect(
|
||||||
|
PROMPT,
|
||||||
|
timeout=(
|
||||||
|
6 if (
|
||||||
|
_non_linux
|
||||||
|
and
|
||||||
|
ci_env
|
||||||
|
) else -1
|
||||||
|
),
|
||||||
|
)
|
||||||
child.sendline(send_char)
|
child.sendline(send_char)
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
|
@ -889,6 +973,11 @@ def test_different_debug_mode_per_actor(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# skip on non-Linux CI
|
||||||
|
@pytest.mark.ctlcs_bish(
|
||||||
|
_non_linux,
|
||||||
|
_ci_env,
|
||||||
|
)
|
||||||
def test_post_mortem_api(
|
def test_post_mortem_api(
|
||||||
spawn,
|
spawn,
|
||||||
ctlc: bool,
|
ctlc: bool,
|
||||||
|
|
@ -1133,14 +1222,20 @@ def test_ctxep_pauses_n_maybe_ipc_breaks(
|
||||||
# closed so verify we see error reporting as well as
|
# closed so verify we see error reporting as well as
|
||||||
# a failed crash-REPL request msg and can CTL-c our way
|
# a failed crash-REPL request msg and can CTL-c our way
|
||||||
# out.
|
# out.
|
||||||
|
|
||||||
|
# ?TODO, match depending on `tpt_proto(s)`?
|
||||||
|
# - [ ] how can we pass it into the script tho?
|
||||||
|
tpt: str = 'UDS'
|
||||||
|
if _non_linux:
|
||||||
|
tpt: str = 'TCP'
|
||||||
|
|
||||||
assert_before(
|
assert_before(
|
||||||
child,
|
child,
|
||||||
['peer IPC channel closed abruptly?',
|
['peer IPC channel closed abruptly?',
|
||||||
'another task closed this fd',
|
'another task closed this fd',
|
||||||
'Debug lock request was CANCELLED?',
|
'Debug lock request was CANCELLED?',
|
||||||
"'MsgpackUDSStream' was already closed locally?",
|
f"'Msgpack{tpt}Stream' was already closed locally?",
|
||||||
"TransportClosed: 'MsgpackUDSStream' was already closed 'by peer'?",
|
f"TransportClosed: 'Msgpack{tpt}Stream' was already closed 'by peer'?",
|
||||||
# ?TODO^? match depending on `tpt_proto(s)`?
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# XXX races on whether these show/hit?
|
# XXX races on whether these show/hit?
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ from .conftest import (
|
||||||
PROMPT,
|
PROMPT,
|
||||||
_pause_msg,
|
_pause_msg,
|
||||||
)
|
)
|
||||||
|
from ..conftest import (
|
||||||
|
no_macos,
|
||||||
|
)
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pexpect.exceptions import (
|
from pexpect.exceptions import (
|
||||||
|
|
@ -42,6 +45,7 @@ if TYPE_CHECKING:
|
||||||
from ..conftest import PexpectSpawner
|
from ..conftest import PexpectSpawner
|
||||||
|
|
||||||
|
|
||||||
|
@no_macos
|
||||||
def test_shield_pause(
|
def test_shield_pause(
|
||||||
spawn: PexpectSpawner,
|
spawn: PexpectSpawner,
|
||||||
):
|
):
|
||||||
|
|
@ -57,6 +61,7 @@ def test_shield_pause(
|
||||||
expect(
|
expect(
|
||||||
child,
|
child,
|
||||||
'Yo my child hanging..?',
|
'Yo my child hanging..?',
|
||||||
|
timeout=3,
|
||||||
)
|
)
|
||||||
assert_before(
|
assert_before(
|
||||||
child,
|
child,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,13 @@ def test_root_passes_tpt_to_sub(
|
||||||
reg_addr: tuple,
|
reg_addr: tuple,
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
):
|
):
|
||||||
|
# XXX NOTE, the `reg_addr` addr won't be the same type as the
|
||||||
|
# `tpt_proto_key` would deliver here unless you pass `--tpt-proto
|
||||||
|
# <tpt_proto_key>` on the CLI.
|
||||||
|
#
|
||||||
|
# if tpt_proto_key == 'uds':
|
||||||
|
# breakpoint()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
enable_transports=[tpt_proto_key],
|
enable_transports=[tpt_proto_key],
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
'''
|
||||||
|
`tractor.msg.*` sub-sys test suite.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
'''
|
||||||
|
`tractor.msg.*` test sub-pkg conf.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
@ -5,6 +5,7 @@ Low-level functional audits for our
|
||||||
B~)
|
B~)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
from __future__ import annotations
|
||||||
from contextlib import (
|
from contextlib import (
|
||||||
contextmanager as cm,
|
contextmanager as cm,
|
||||||
# nullcontext,
|
# nullcontext,
|
||||||
|
|
@ -20,7 +21,7 @@ from msgspec import (
|
||||||
# structs,
|
# structs,
|
||||||
# msgpack,
|
# msgpack,
|
||||||
Raw,
|
Raw,
|
||||||
# Struct,
|
Struct,
|
||||||
ValidationError,
|
ValidationError,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -46,6 +47,11 @@ from tractor.msg import (
|
||||||
apply_codec,
|
apply_codec,
|
||||||
current_codec,
|
current_codec,
|
||||||
)
|
)
|
||||||
|
from tractor.msg._codec import (
|
||||||
|
default_builtins,
|
||||||
|
mk_dec_hook,
|
||||||
|
mk_codec_from_spec,
|
||||||
|
)
|
||||||
from tractor.msg.types import (
|
from tractor.msg.types import (
|
||||||
log,
|
log,
|
||||||
Started,
|
Started,
|
||||||
|
|
@ -743,6 +749,143 @@ def test_ext_types_over_ipc(
|
||||||
assert exc.boxed_type is TypeError
|
assert exc.boxed_type is TypeError
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
Test the auto enc & dec hooks
|
||||||
|
|
||||||
|
Create a codec which will work for:
|
||||||
|
- builtins
|
||||||
|
- custom types
|
||||||
|
- lists of custom types
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
class BytesTestClass(Struct, tag=True):
|
||||||
|
raw: bytes
|
||||||
|
|
||||||
|
def encode(self) -> bytes:
|
||||||
|
return self.raw
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_bytes(self, raw: bytes) -> BytesTestClass:
|
||||||
|
return BytesTestClass(raw=raw)
|
||||||
|
|
||||||
|
|
||||||
|
class StrTestClass(Struct, tag=True):
|
||||||
|
s: str
|
||||||
|
|
||||||
|
def encode(self) -> str:
|
||||||
|
return self.s
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_str(self, s: str) -> StrTestClass:
|
||||||
|
return StrTestClass(s=s)
|
||||||
|
|
||||||
|
|
||||||
|
class IntTestClass(Struct, tag=True):
|
||||||
|
num: int
|
||||||
|
|
||||||
|
def encode(self) -> int:
|
||||||
|
return self.num
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_int(self, num: int) -> IntTestClass:
|
||||||
|
return IntTestClass(num=num)
|
||||||
|
|
||||||
|
|
||||||
|
builtins = tuple((
|
||||||
|
builtin
|
||||||
|
for builtin in default_builtins
|
||||||
|
if builtin is not list
|
||||||
|
))
|
||||||
|
|
||||||
|
TestClasses = (BytesTestClass, StrTestClass, IntTestClass)
|
||||||
|
|
||||||
|
|
||||||
|
TestSpec = (
|
||||||
|
*TestClasses, list[Union[*TestClasses]]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
test_codec = mk_codec_from_spec(
|
||||||
|
spec=TestSpec
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@tractor.context
|
||||||
|
async def child_custom_codec(
|
||||||
|
ctx: tractor.Context,
|
||||||
|
msgs: list[Union[*TestSpec]],
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Apply codec and send all msgs passed through stream
|
||||||
|
|
||||||
|
'''
|
||||||
|
with (
|
||||||
|
apply_codec(test_codec),
|
||||||
|
limit_plds(
|
||||||
|
test_codec.pld_spec,
|
||||||
|
dec_hook=mk_dec_hook(TestSpec),
|
||||||
|
ext_types=TestSpec + builtins
|
||||||
|
),
|
||||||
|
):
|
||||||
|
await ctx.started(None)
|
||||||
|
async with ctx.open_stream() as stream:
|
||||||
|
for msg in msgs:
|
||||||
|
await stream.send(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def test_multi_custom_codec():
|
||||||
|
'''
|
||||||
|
Open subactor setup codec and pld_rx and wait to receive & assert from
|
||||||
|
stream
|
||||||
|
|
||||||
|
'''
|
||||||
|
msgs = [
|
||||||
|
None,
|
||||||
|
True, False,
|
||||||
|
0xdeadbeef,
|
||||||
|
.42069,
|
||||||
|
b'deadbeef',
|
||||||
|
BytesTestClass(raw=b'deadbeef'),
|
||||||
|
StrTestClass(s='deadbeef'),
|
||||||
|
IntTestClass(num=0xdeadbeef),
|
||||||
|
[
|
||||||
|
BytesTestClass(raw=b'deadbeef'),
|
||||||
|
StrTestClass(s='deadbeef'),
|
||||||
|
IntTestClass(num=0xdeadbeef),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
async with tractor.open_nursery() as an:
|
||||||
|
p: tractor.Portal = await an.start_actor(
|
||||||
|
'child',
|
||||||
|
enable_modules=[__name__],
|
||||||
|
)
|
||||||
|
async with (
|
||||||
|
p.open_context(
|
||||||
|
child_custom_codec,
|
||||||
|
msgs=msgs,
|
||||||
|
) as (ctx, _),
|
||||||
|
ctx.open_stream() as ipc
|
||||||
|
):
|
||||||
|
with (
|
||||||
|
apply_codec(test_codec),
|
||||||
|
limit_plds(
|
||||||
|
test_codec.pld_spec,
|
||||||
|
dec_hook=mk_dec_hook(TestSpec),
|
||||||
|
ext_types=TestSpec + builtins
|
||||||
|
)
|
||||||
|
):
|
||||||
|
msg_iter = iter(msgs)
|
||||||
|
async for recv_msg in ipc:
|
||||||
|
assert recv_msg == next(msg_iter)
|
||||||
|
|
||||||
|
await p.cancel_actor()
|
||||||
|
|
||||||
|
trio.run(main)
|
||||||
|
|
||||||
|
|
||||||
# def chk_pld_type(
|
# def chk_pld_type(
|
||||||
# payload_spec: Type[Struct]|Any,
|
# payload_spec: Type[Struct]|Any,
|
||||||
# pld: Any,
|
# pld: Any,
|
||||||
|
|
@ -0,0 +1,240 @@
|
||||||
|
'''
|
||||||
|
Unit tests for `tractor.msg.pretty_struct`
|
||||||
|
private-field filtering in `pformat()`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from tractor.msg.pretty_struct import (
|
||||||
|
Struct,
|
||||||
|
pformat,
|
||||||
|
iter_struct_ppfmt_lines,
|
||||||
|
)
|
||||||
|
from tractor.msg._codec import (
|
||||||
|
MsgDec,
|
||||||
|
mk_dec,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ------ test struct definitions ------ #
|
||||||
|
|
||||||
|
class PublicOnly(Struct):
|
||||||
|
'''
|
||||||
|
All-public fields for baseline testing.
|
||||||
|
|
||||||
|
'''
|
||||||
|
name: str = 'alice'
|
||||||
|
age: int = 30
|
||||||
|
|
||||||
|
|
||||||
|
class PrivateOnly(Struct):
|
||||||
|
'''
|
||||||
|
Only underscore-prefixed (private) fields.
|
||||||
|
|
||||||
|
'''
|
||||||
|
_secret: str = 'hidden'
|
||||||
|
_internal: int = 99
|
||||||
|
|
||||||
|
|
||||||
|
class MixedFields(Struct):
|
||||||
|
'''
|
||||||
|
Mix of public and private fields.
|
||||||
|
|
||||||
|
'''
|
||||||
|
name: str = 'bob'
|
||||||
|
_hidden: int = 42
|
||||||
|
value: float = 3.14
|
||||||
|
_meta: str = 'internal'
|
||||||
|
|
||||||
|
|
||||||
|
class Inner(
|
||||||
|
Struct,
|
||||||
|
frozen=True,
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Frozen inner struct with a private field,
|
||||||
|
for nesting tests.
|
||||||
|
|
||||||
|
'''
|
||||||
|
x: int = 1
|
||||||
|
_secret: str = 'nope'
|
||||||
|
|
||||||
|
|
||||||
|
class Outer(Struct):
|
||||||
|
'''
|
||||||
|
Outer struct nesting an `Inner`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
label: str = 'outer'
|
||||||
|
inner: Inner = Inner()
|
||||||
|
|
||||||
|
|
||||||
|
class EmptyStruct(Struct):
|
||||||
|
'''
|
||||||
|
Struct with zero fields.
|
||||||
|
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# ------ tests ------ #
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'struct_and_expected',
|
||||||
|
[
|
||||||
|
(
|
||||||
|
PublicOnly(),
|
||||||
|
{
|
||||||
|
'shown': ['name', 'age'],
|
||||||
|
'hidden': [],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
MixedFields(),
|
||||||
|
{
|
||||||
|
'shown': ['name', 'value'],
|
||||||
|
'hidden': ['_hidden', '_meta'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
PrivateOnly(),
|
||||||
|
{
|
||||||
|
'shown': [],
|
||||||
|
'hidden': ['_secret', '_internal'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
ids=[
|
||||||
|
'all-public',
|
||||||
|
'mixed-pub-priv',
|
||||||
|
'all-private',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_field_visibility_in_pformat(
|
||||||
|
struct_and_expected: tuple[
|
||||||
|
Struct,
|
||||||
|
dict[str, list[str]],
|
||||||
|
],
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Verify `pformat()` shows public fields
|
||||||
|
and hides `_`-prefixed private fields.
|
||||||
|
|
||||||
|
'''
|
||||||
|
(
|
||||||
|
struct,
|
||||||
|
expected,
|
||||||
|
) = struct_and_expected
|
||||||
|
output: str = pformat(struct)
|
||||||
|
|
||||||
|
for field_name in expected['shown']:
|
||||||
|
assert field_name in output, (
|
||||||
|
f'{field_name!r} should appear in:\n'
|
||||||
|
f'{output}'
|
||||||
|
)
|
||||||
|
|
||||||
|
for field_name in expected['hidden']:
|
||||||
|
assert field_name not in output, (
|
||||||
|
f'{field_name!r} should NOT appear in:\n'
|
||||||
|
f'{output}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_iter_ppfmt_lines_skips_private():
|
||||||
|
'''
|
||||||
|
Directly verify `iter_struct_ppfmt_lines()`
|
||||||
|
never yields tuples with `_`-prefixed field
|
||||||
|
names.
|
||||||
|
|
||||||
|
'''
|
||||||
|
struct = MixedFields()
|
||||||
|
lines: list[tuple[str, str]] = list(
|
||||||
|
iter_struct_ppfmt_lines(
|
||||||
|
struct,
|
||||||
|
field_indent=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# should have lines for public fields only
|
||||||
|
assert len(lines) == 2
|
||||||
|
|
||||||
|
for _prefix, line_content in lines:
|
||||||
|
field_name: str = (
|
||||||
|
line_content.split(':')[0].strip()
|
||||||
|
)
|
||||||
|
assert not field_name.startswith('_'), (
|
||||||
|
f'private field leaked: {field_name!r}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested_struct_filters_inner_private():
|
||||||
|
'''
|
||||||
|
Verify that nested struct's private fields
|
||||||
|
are also filtered out during recursion.
|
||||||
|
|
||||||
|
'''
|
||||||
|
outer = Outer()
|
||||||
|
output: str = pformat(outer)
|
||||||
|
|
||||||
|
# outer's public field
|
||||||
|
assert 'label' in output
|
||||||
|
|
||||||
|
# inner's public field (recursed into)
|
||||||
|
assert 'x' in output
|
||||||
|
|
||||||
|
# inner's private field must be hidden
|
||||||
|
assert '_secret' not in output
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_struct_pformat():
|
||||||
|
'''
|
||||||
|
An empty struct should produce a valid
|
||||||
|
`pformat()` result with no field lines.
|
||||||
|
|
||||||
|
'''
|
||||||
|
output: str = pformat(EmptyStruct())
|
||||||
|
assert 'EmptyStruct(' in output
|
||||||
|
assert output.rstrip().endswith(')')
|
||||||
|
|
||||||
|
# no field lines => only struct header+footer
|
||||||
|
lines: list[tuple[str, str]] = list(
|
||||||
|
iter_struct_ppfmt_lines(
|
||||||
|
EmptyStruct(),
|
||||||
|
field_indent=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert lines == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_real_msgdec_pformat_hides_private():
|
||||||
|
'''
|
||||||
|
Verify `pformat()` on a real `MsgDec`
|
||||||
|
hides the `_dec` internal field.
|
||||||
|
|
||||||
|
NOTE: `MsgDec.__repr__` is custom and does
|
||||||
|
NOT call `pformat()`, so we call it directly.
|
||||||
|
|
||||||
|
'''
|
||||||
|
dec: MsgDec = mk_dec(spec=int)
|
||||||
|
output: str = pformat(dec)
|
||||||
|
|
||||||
|
# the private `_dec` field should be filtered
|
||||||
|
assert '_dec' not in output
|
||||||
|
|
||||||
|
# but the struct type name should be present
|
||||||
|
assert 'MsgDec(' in output
|
||||||
|
|
||||||
|
|
||||||
|
def test_pformat_repr_integration():
|
||||||
|
'''
|
||||||
|
Verify that `Struct.__repr__()` (which calls
|
||||||
|
`pformat()`) also hides private fields for
|
||||||
|
custom structs that do NOT override `__repr__`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
mixed = MixedFields()
|
||||||
|
output: str = repr(mixed)
|
||||||
|
|
||||||
|
assert 'name' in output
|
||||||
|
assert 'value' in output
|
||||||
|
assert '_hidden' not in output
|
||||||
|
assert '_meta' not in output
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
"""
|
'''
|
||||||
Bidirectional streaming.
|
Audit the simplest inter-actor bidirectional (streaming)
|
||||||
|
msg patterns.
|
||||||
|
|
||||||
"""
|
'''
|
||||||
|
from __future__ import annotations
|
||||||
|
from typing import (
|
||||||
|
Callable,
|
||||||
|
)
|
||||||
import pytest
|
import pytest
|
||||||
import trio
|
import trio
|
||||||
import tractor
|
import tractor
|
||||||
|
|
@ -9,10 +14,8 @@ import tractor
|
||||||
|
|
||||||
@tractor.context
|
@tractor.context
|
||||||
async def simple_rpc(
|
async def simple_rpc(
|
||||||
|
|
||||||
ctx: tractor.Context,
|
ctx: tractor.Context,
|
||||||
data: int,
|
data: int,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Test a small ping-pong server.
|
Test a small ping-pong server.
|
||||||
|
|
@ -39,15 +42,13 @@ async def simple_rpc(
|
||||||
|
|
||||||
@tractor.context
|
@tractor.context
|
||||||
async def simple_rpc_with_forloop(
|
async def simple_rpc_with_forloop(
|
||||||
|
|
||||||
ctx: tractor.Context,
|
ctx: tractor.Context,
|
||||||
data: int,
|
data: int,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Same as previous test but using ``async for`` syntax/api.
|
'''
|
||||||
|
Same as previous test but using `async for` syntax/api.
|
||||||
"""
|
|
||||||
|
|
||||||
|
'''
|
||||||
# signal to parent that we're up
|
# signal to parent that we're up
|
||||||
await ctx.started(data + 1)
|
await ctx.started(data + 1)
|
||||||
|
|
||||||
|
|
@ -68,62 +69,78 @@ async def simple_rpc_with_forloop(
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'use_async_for',
|
'use_async_for',
|
||||||
[True, False],
|
[
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
],
|
||||||
|
ids='use_async_for={}'.format,
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'server_func',
|
'server_func',
|
||||||
[simple_rpc, simple_rpc_with_forloop],
|
[
|
||||||
|
simple_rpc,
|
||||||
|
simple_rpc_with_forloop,
|
||||||
|
],
|
||||||
|
ids='server_func={}'.format,
|
||||||
)
|
)
|
||||||
def test_simple_rpc(server_func, use_async_for):
|
def test_simple_rpc(
|
||||||
|
server_func: Callable,
|
||||||
|
use_async_for: bool,
|
||||||
|
loglevel: str,
|
||||||
|
debug_mode: bool,
|
||||||
|
):
|
||||||
'''
|
'''
|
||||||
The simplest request response pattern.
|
The simplest request response pattern.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async def main():
|
async def main():
|
||||||
async with tractor.open_nursery() as n:
|
with trio.fail_after(6):
|
||||||
|
async with tractor.open_nursery(
|
||||||
|
loglevel=loglevel,
|
||||||
|
debug_mode=debug_mode,
|
||||||
|
) as an:
|
||||||
|
portal: tractor.Portal = await an.start_actor(
|
||||||
|
'rpc_server',
|
||||||
|
enable_modules=[__name__],
|
||||||
|
)
|
||||||
|
|
||||||
portal = await n.start_actor(
|
async with portal.open_context(
|
||||||
'rpc_server',
|
server_func, # taken from pytest parameterization
|
||||||
enable_modules=[__name__],
|
data=10,
|
||||||
)
|
) as (ctx, sent):
|
||||||
|
|
||||||
async with portal.open_context(
|
assert sent == 11
|
||||||
server_func, # taken from pytest parameterization
|
|
||||||
data=10,
|
|
||||||
) as (ctx, sent):
|
|
||||||
|
|
||||||
assert sent == 11
|
async with ctx.open_stream() as stream:
|
||||||
|
|
||||||
async with ctx.open_stream() as stream:
|
if use_async_for:
|
||||||
|
|
||||||
if use_async_for:
|
count = 0
|
||||||
|
# receive msgs using async for style
|
||||||
count = 0
|
|
||||||
# receive msgs using async for style
|
|
||||||
print('ping')
|
|
||||||
await stream.send('ping')
|
|
||||||
|
|
||||||
async for msg in stream:
|
|
||||||
assert msg == 'pong'
|
|
||||||
print('ping')
|
print('ping')
|
||||||
await stream.send('ping')
|
await stream.send('ping')
|
||||||
count += 1
|
|
||||||
|
|
||||||
if count >= 9:
|
async for msg in stream:
|
||||||
break
|
assert msg == 'pong'
|
||||||
|
print('ping')
|
||||||
|
await stream.send('ping')
|
||||||
|
count += 1
|
||||||
|
|
||||||
else:
|
if count >= 9:
|
||||||
# classic send/receive style
|
break
|
||||||
for _ in range(10):
|
|
||||||
|
|
||||||
print('ping')
|
else:
|
||||||
await stream.send('ping')
|
# classic send/receive style
|
||||||
assert await stream.receive() == 'pong'
|
for _ in range(10):
|
||||||
|
|
||||||
# stream should terminate here
|
print('ping')
|
||||||
|
await stream.send('ping')
|
||||||
|
assert await stream.receive() == 'pong'
|
||||||
|
|
||||||
# final context result(s) should be consumed here in __aexit__()
|
# stream should terminate here
|
||||||
|
|
||||||
await portal.cancel_actor()
|
# final context result(s) should be consumed here in __aexit__()
|
||||||
|
|
||||||
|
await portal.cancel_actor()
|
||||||
|
|
||||||
trio.run(main)
|
trio.run(main)
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,6 @@ def test_ipc_channel_break_during_stream(
|
||||||
# a user sending ctl-c by raising a KBI.
|
# a user sending ctl-c by raising a KBI.
|
||||||
if pre_aclose_msgstream:
|
if pre_aclose_msgstream:
|
||||||
expect_final_exc = KeyboardInterrupt
|
expect_final_exc = KeyboardInterrupt
|
||||||
if tpt_proto == 'uds':
|
|
||||||
expect_final_exc = TransportClosed
|
|
||||||
expect_final_cause = trio.BrokenResourceError
|
|
||||||
|
|
||||||
# XXX OLD XXX
|
# XXX OLD XXX
|
||||||
# if child calls `MsgStream.aclose()` then expect EoC.
|
# if child calls `MsgStream.aclose()` then expect EoC.
|
||||||
|
|
@ -169,10 +166,6 @@ def test_ipc_channel_break_during_stream(
|
||||||
if pre_aclose_msgstream:
|
if pre_aclose_msgstream:
|
||||||
expect_final_exc = KeyboardInterrupt
|
expect_final_exc = KeyboardInterrupt
|
||||||
|
|
||||||
if tpt_proto == 'uds':
|
|
||||||
expect_final_exc = TransportClosed
|
|
||||||
expect_final_cause = trio.BrokenResourceError
|
|
||||||
|
|
||||||
# NOTE when the parent IPC side dies (even if the child does as well
|
# NOTE when the parent IPC side dies (even if the child does as well
|
||||||
# but the child fails BEFORE the parent) we always expect the
|
# but the child fails BEFORE the parent) we always expect the
|
||||||
# IPC layer to raise a closed-resource, NEVER do we expect
|
# IPC layer to raise a closed-resource, NEVER do we expect
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ from tractor._testing import (
|
||||||
from .conftest import no_windows
|
from .conftest import no_windows
|
||||||
|
|
||||||
|
|
||||||
def is_win():
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
return platform.system() == 'Windows'
|
_friggin_windows: bool = platform.system() == 'Windows'
|
||||||
|
|
||||||
|
|
||||||
async def assert_err(delay=0):
|
async def assert_err(delay=0):
|
||||||
|
|
@ -431,7 +431,7 @@ async def test_nested_multierrors(loglevel, start_method):
|
||||||
for subexc in err.exceptions:
|
for subexc in err.exceptions:
|
||||||
|
|
||||||
# verify first level actor errors are wrapped as remote
|
# verify first level actor errors are wrapped as remote
|
||||||
if is_win():
|
if _friggin_windows:
|
||||||
|
|
||||||
# windows is often too slow and cancellation seems
|
# windows is often too slow and cancellation seems
|
||||||
# to happen before an actor is spawned
|
# to happen before an actor is spawned
|
||||||
|
|
@ -464,7 +464,7 @@ async def test_nested_multierrors(loglevel, start_method):
|
||||||
# XXX not sure what's up with this..
|
# XXX not sure what's up with this..
|
||||||
# on windows sometimes spawning is just too slow and
|
# on windows sometimes spawning is just too slow and
|
||||||
# we get back the (sent) cancel signal instead
|
# we get back the (sent) cancel signal instead
|
||||||
if is_win():
|
if _friggin_windows:
|
||||||
if isinstance(subexc, tractor.RemoteActorError):
|
if isinstance(subexc, tractor.RemoteActorError):
|
||||||
assert subexc.boxed_type in (
|
assert subexc.boxed_type in (
|
||||||
BaseExceptionGroup,
|
BaseExceptionGroup,
|
||||||
|
|
@ -507,17 +507,22 @@ def test_cancel_via_SIGINT(
|
||||||
|
|
||||||
@no_windows
|
@no_windows
|
||||||
def test_cancel_via_SIGINT_other_task(
|
def test_cancel_via_SIGINT_other_task(
|
||||||
loglevel,
|
loglevel: str,
|
||||||
start_method,
|
start_method: str,
|
||||||
spawn_backend,
|
spawn_backend: str,
|
||||||
):
|
):
|
||||||
"""Ensure that a control-C (SIGINT) signal cancels both the parent
|
'''
|
||||||
and child processes in trionic fashion even a subprocess is started
|
Ensure that a control-C (SIGINT) signal cancels both the parent
|
||||||
from a seperate ``trio`` child task.
|
and child processes in trionic fashion even a subprocess is
|
||||||
"""
|
started from a seperate ``trio`` child task.
|
||||||
pid = os.getpid()
|
|
||||||
timeout: float = 2
|
'''
|
||||||
if is_win(): # smh
|
pid: int = os.getpid()
|
||||||
|
timeout: float = (
|
||||||
|
4 if _non_linux
|
||||||
|
else 2
|
||||||
|
)
|
||||||
|
if _friggin_windows: # smh
|
||||||
timeout += 1
|
timeout += 1
|
||||||
|
|
||||||
async def spawn_and_sleep_forever(
|
async def spawn_and_sleep_forever(
|
||||||
|
|
@ -644,7 +649,11 @@ def test_cancel_while_childs_child_in_sync_sleep(
|
||||||
#
|
#
|
||||||
# delay = 1 # no AssertionError in eg, TooSlowError raised.
|
# delay = 1 # no AssertionError in eg, TooSlowError raised.
|
||||||
# delay = 2 # is AssertionError in eg AND no TooSlowError !?
|
# delay = 2 # is AssertionError in eg AND no TooSlowError !?
|
||||||
delay = 4 # is AssertionError in eg AND no _cs cancellation.
|
# is AssertionError in eg AND no _cs cancellation.
|
||||||
|
delay = (
|
||||||
|
6 if _non_linux
|
||||||
|
else 4
|
||||||
|
)
|
||||||
|
|
||||||
with trio.fail_after(delay) as _cs:
|
with trio.fail_after(delay) as _cs:
|
||||||
# with trio.CancelScope() as cs:
|
# with trio.CancelScope() as cs:
|
||||||
|
|
@ -696,7 +705,7 @@ def test_fast_graceful_cancel_when_spawn_task_in_soft_proc_wait_for_daemon(
|
||||||
kbi_delay = 0.5
|
kbi_delay = 0.5
|
||||||
timeout: float = 2.9
|
timeout: float = 2.9
|
||||||
|
|
||||||
if is_win(): # smh
|
if _friggin_windows: # smh
|
||||||
timeout += 1
|
timeout += 1
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,15 @@ from tractor import RemoteActorError
|
||||||
|
|
||||||
|
|
||||||
async def aio_streamer(
|
async def aio_streamer(
|
||||||
from_trio: asyncio.Queue,
|
chan: tractor.to_asyncio.LinkedTaskChannel,
|
||||||
to_trio: trio.abc.SendChannel,
|
|
||||||
) -> trio.abc.ReceiveChannel:
|
) -> trio.abc.ReceiveChannel:
|
||||||
|
|
||||||
# required first msg to sync caller
|
# required first msg to sync caller
|
||||||
to_trio.send_nowait(None)
|
chan.started_nowait(None)
|
||||||
|
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
for i in cycle(range(10)):
|
for i in cycle(range(10)):
|
||||||
to_trio.send_nowait(i)
|
chan.send_nowait(i)
|
||||||
await asyncio.sleep(0.01)
|
await asyncio.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -69,7 +68,7 @@ async def wrapper_mngr(
|
||||||
else:
|
else:
|
||||||
async with tractor.to_asyncio.open_channel_from(
|
async with tractor.to_asyncio.open_channel_from(
|
||||||
aio_streamer,
|
aio_streamer,
|
||||||
) as (first, from_aio):
|
) as (from_aio, first):
|
||||||
assert not first
|
assert not first
|
||||||
|
|
||||||
# cache it so next task uses broadcast receiver
|
# cache it so next task uses broadcast receiver
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ MESSAGE = 'tractoring at full speed'
|
||||||
|
|
||||||
|
|
||||||
def test_empty_mngrs_input_raises() -> None:
|
def test_empty_mngrs_input_raises() -> None:
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
with trio.fail_after(3):
|
with trio.fail_after(3):
|
||||||
async with (
|
async with (
|
||||||
|
|
@ -56,25 +55,39 @@ async def worker(
|
||||||
print(msg)
|
print(msg)
|
||||||
assert msg == MESSAGE
|
assert msg == MESSAGE
|
||||||
|
|
||||||
# TODO: does this ever cause a hang
|
# ?TODO, does this ever cause a hang?
|
||||||
# assert 0
|
# assert 0
|
||||||
|
|
||||||
|
|
||||||
|
# ?TODO, but needs a fn-scoped tpt_proto fixture..
|
||||||
|
# @pytest.mark.no_tpt('uds')
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_streaming_to_actor_cluster() -> None:
|
async def test_streaming_to_actor_cluster(
|
||||||
|
tpt_proto: str,
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Open an actor "cluster" using the (experimental) `._clustering`
|
||||||
|
API and conduct standard inter-task-ctx streaming.
|
||||||
|
|
||||||
async with (
|
'''
|
||||||
open_actor_cluster(modules=[__name__]) as portals,
|
if tpt_proto == 'uds':
|
||||||
|
pytest.skip(
|
||||||
|
f'Test currently fails with tpt-proto={tpt_proto!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
gather_contexts(
|
with trio.fail_after(6):
|
||||||
mngrs=[p.open_context(worker) for p in portals.values()],
|
async with (
|
||||||
) as contexts,
|
open_actor_cluster(modules=[__name__]) as portals,
|
||||||
|
|
||||||
gather_contexts(
|
gather_contexts(
|
||||||
mngrs=[ctx[0].open_stream() for ctx in contexts],
|
mngrs=[p.open_context(worker) for p in portals.values()],
|
||||||
) as streams,
|
) as contexts,
|
||||||
|
|
||||||
):
|
gather_contexts(
|
||||||
with trio.move_on_after(1):
|
mngrs=[ctx[0].open_stream() for ctx in contexts],
|
||||||
for stream in itertools.cycle(streams):
|
) as streams,
|
||||||
await stream.send(MESSAGE)
|
|
||||||
|
):
|
||||||
|
with trio.move_on_after(1):
|
||||||
|
for stream in itertools.cycle(streams):
|
||||||
|
await stream.send(MESSAGE)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from itertools import count
|
||||||
import math
|
import math
|
||||||
import platform
|
import platform
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
import sys
|
||||||
from typing import (
|
from typing import (
|
||||||
Callable,
|
Callable,
|
||||||
)
|
)
|
||||||
|
|
@ -941,6 +942,11 @@ def test_one_end_stream_not_opened(
|
||||||
from tractor._runtime import Actor
|
from tractor._runtime import Actor
|
||||||
buf_size = buf_size_increase + Actor.msg_buffer_size
|
buf_size = buf_size_increase + Actor.msg_buffer_size
|
||||||
|
|
||||||
|
timeout: float = (
|
||||||
|
1 if sys.platform == 'linux'
|
||||||
|
else 3
|
||||||
|
)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
|
|
@ -950,7 +956,7 @@ def test_one_end_stream_not_opened(
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
|
|
||||||
with trio.fail_after(1):
|
with trio.fail_after(timeout):
|
||||||
async with portal.open_context(
|
async with portal.open_context(
|
||||||
entrypoint,
|
entrypoint,
|
||||||
) as (ctx, sent):
|
) as (ctx, sent):
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
"""
|
"""
|
||||||
Actor "discovery" testing
|
Discovery subsys.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import platform
|
import platform
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import itertools
|
import itertools
|
||||||
|
import time
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -17,7 +20,9 @@ import trio
|
||||||
|
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_reg_then_unreg(reg_addr):
|
async def test_reg_then_unreg(
|
||||||
|
reg_addr: tuple,
|
||||||
|
):
|
||||||
actor = tractor.current_actor()
|
actor = tractor.current_actor()
|
||||||
assert actor.is_arbiter
|
assert actor.is_arbiter
|
||||||
assert len(actor._registry) == 1 # only self is registered
|
assert len(actor._registry) == 1 # only self is registered
|
||||||
|
|
@ -27,7 +32,7 @@ async def test_reg_then_unreg(reg_addr):
|
||||||
) as n:
|
) as n:
|
||||||
|
|
||||||
portal = await n.start_actor('actor', enable_modules=[__name__])
|
portal = await n.start_actor('actor', enable_modules=[__name__])
|
||||||
uid = portal.channel.uid
|
uid = portal.channel.aid.uid
|
||||||
|
|
||||||
async with tractor.get_registry(reg_addr) as aportal:
|
async with tractor.get_registry(reg_addr) as aportal:
|
||||||
# this local actor should be the arbiter
|
# this local actor should be the arbiter
|
||||||
|
|
@ -82,11 +87,15 @@ async def say_hello_use_wait(
|
||||||
|
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
@pytest.mark.parametrize('func', [say_hello, say_hello_use_wait])
|
@pytest.mark.parametrize(
|
||||||
|
'func',
|
||||||
|
[say_hello,
|
||||||
|
say_hello_use_wait]
|
||||||
|
)
|
||||||
async def test_trynamic_trio(
|
async def test_trynamic_trio(
|
||||||
func,
|
func: Callable,
|
||||||
start_method,
|
start_method: str,
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Root actor acting as the "director" and running one-shot-task-actors
|
Root actor acting as the "director" and running one-shot-task-actors
|
||||||
|
|
@ -119,7 +128,10 @@ async def stream_forever():
|
||||||
await trio.sleep(0.01)
|
await trio.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
async def cancel(use_signal, delay=0):
|
async def cancel(
|
||||||
|
use_signal: bool,
|
||||||
|
delay: float = 0,
|
||||||
|
):
|
||||||
# hold on there sally
|
# hold on there sally
|
||||||
await trio.sleep(delay)
|
await trio.sleep(delay)
|
||||||
|
|
||||||
|
|
@ -132,13 +144,15 @@ async def cancel(use_signal, delay=0):
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
|
|
||||||
|
|
||||||
async def stream_from(portal):
|
async def stream_from(portal: tractor.Portal):
|
||||||
async with portal.open_stream_from(stream_forever) as stream:
|
async with portal.open_stream_from(stream_forever) as stream:
|
||||||
async for value in stream:
|
async for value in stream:
|
||||||
print(value)
|
print(value)
|
||||||
|
|
||||||
|
|
||||||
async def unpack_reg(actor_or_portal):
|
async def unpack_reg(
|
||||||
|
actor_or_portal: tractor.Portal|tractor.Actor,
|
||||||
|
):
|
||||||
'''
|
'''
|
||||||
Get and unpack a "registry" RPC request from the "arbiter" registry
|
Get and unpack a "registry" RPC request from the "arbiter" registry
|
||||||
system.
|
system.
|
||||||
|
|
@ -173,7 +187,9 @@ async def spawn_and_check_registry(
|
||||||
registry_addrs=[reg_addr],
|
registry_addrs=[reg_addr],
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
):
|
):
|
||||||
async with tractor.get_registry(reg_addr) as portal:
|
async with tractor.get_registry(
|
||||||
|
addr=reg_addr,
|
||||||
|
) as portal:
|
||||||
# runtime needs to be up to call this
|
# runtime needs to be up to call this
|
||||||
actor = tractor.current_actor()
|
actor = tractor.current_actor()
|
||||||
|
|
||||||
|
|
@ -190,7 +206,7 @@ async def spawn_and_check_registry(
|
||||||
|
|
||||||
# ensure current actor is registered
|
# ensure current actor is registered
|
||||||
registry: dict = await get_reg()
|
registry: dict = await get_reg()
|
||||||
assert actor.uid in registry
|
assert actor.aid.uid in registry
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with tractor.open_nursery() as an:
|
async with tractor.open_nursery() as an:
|
||||||
|
|
@ -238,18 +254,31 @@ async def spawn_and_check_registry(
|
||||||
|
|
||||||
# all subactors should have de-registered
|
# all subactors should have de-registered
|
||||||
registry = await get_reg()
|
registry = await get_reg()
|
||||||
assert len(registry) == extra
|
start: float = time.time()
|
||||||
assert actor.uid in registry
|
while (
|
||||||
|
not (len(registry) == extra)
|
||||||
|
and
|
||||||
|
(time.time() - start) < 5
|
||||||
|
):
|
||||||
|
print(
|
||||||
|
f'Waiting for remaining subs to dereg..\n'
|
||||||
|
f'{registry!r}\n'
|
||||||
|
)
|
||||||
|
await trio.sleep(0.3)
|
||||||
|
else:
|
||||||
|
assert len(registry) == extra
|
||||||
|
|
||||||
|
assert actor.aid.uid in registry
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('use_signal', [False, True])
|
@pytest.mark.parametrize('use_signal', [False, True])
|
||||||
@pytest.mark.parametrize('with_streaming', [False, True])
|
@pytest.mark.parametrize('with_streaming', [False, True])
|
||||||
def test_subactors_unregister_on_cancel(
|
def test_subactors_unregister_on_cancel(
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
start_method,
|
start_method: str,
|
||||||
use_signal,
|
use_signal: bool,
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
with_streaming,
|
with_streaming: bool,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Verify that cancelling a nursery results in all subactors
|
Verify that cancelling a nursery results in all subactors
|
||||||
|
|
@ -274,15 +303,17 @@ def test_subactors_unregister_on_cancel(
|
||||||
def test_subactors_unregister_on_cancel_remote_daemon(
|
def test_subactors_unregister_on_cancel_remote_daemon(
|
||||||
daemon: subprocess.Popen,
|
daemon: subprocess.Popen,
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
start_method,
|
start_method: str,
|
||||||
use_signal,
|
use_signal: bool,
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
with_streaming,
|
with_streaming: bool,
|
||||||
):
|
):
|
||||||
"""Verify that cancelling a nursery results in all subactors
|
'''
|
||||||
deregistering themselves with a **remote** (not in the local process
|
Verify that cancelling a nursery results in all subactors
|
||||||
tree) arbiter.
|
deregistering themselves with a **remote** (not in the local
|
||||||
"""
|
process tree) arbiter.
|
||||||
|
|
||||||
|
'''
|
||||||
with pytest.raises(KeyboardInterrupt):
|
with pytest.raises(KeyboardInterrupt):
|
||||||
trio.run(
|
trio.run(
|
||||||
partial(
|
partial(
|
||||||
|
|
@ -367,21 +398,23 @@ async def close_chans_before_nursery(
|
||||||
|
|
||||||
# all subactors should have de-registered
|
# all subactors should have de-registered
|
||||||
registry = await get_reg()
|
registry = await get_reg()
|
||||||
assert portal1.channel.uid not in registry
|
assert portal1.channel.aid.uid not in registry
|
||||||
assert portal2.channel.uid not in registry
|
assert portal2.channel.aid.uid not in registry
|
||||||
assert len(registry) == entries_at_end
|
assert len(registry) == entries_at_end
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('use_signal', [False, True])
|
@pytest.mark.parametrize('use_signal', [False, True])
|
||||||
def test_close_channel_explicit(
|
def test_close_channel_explicit(
|
||||||
start_method,
|
start_method: str,
|
||||||
use_signal,
|
use_signal: bool,
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
):
|
):
|
||||||
"""Verify that closing a stream explicitly and killing the actor's
|
'''
|
||||||
|
Verify that closing a stream explicitly and killing the actor's
|
||||||
"root nursery" **before** the containing nursery tears down also
|
"root nursery" **before** the containing nursery tears down also
|
||||||
results in subactor(s) deregistering from the arbiter.
|
results in subactor(s) deregistering from the arbiter.
|
||||||
"""
|
|
||||||
|
'''
|
||||||
with pytest.raises(KeyboardInterrupt):
|
with pytest.raises(KeyboardInterrupt):
|
||||||
trio.run(
|
trio.run(
|
||||||
partial(
|
partial(
|
||||||
|
|
@ -396,14 +429,16 @@ def test_close_channel_explicit(
|
||||||
@pytest.mark.parametrize('use_signal', [False, True])
|
@pytest.mark.parametrize('use_signal', [False, True])
|
||||||
def test_close_channel_explicit_remote_arbiter(
|
def test_close_channel_explicit_remote_arbiter(
|
||||||
daemon: subprocess.Popen,
|
daemon: subprocess.Popen,
|
||||||
start_method,
|
start_method: str,
|
||||||
use_signal,
|
use_signal: bool,
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
):
|
):
|
||||||
"""Verify that closing a stream explicitly and killing the actor's
|
'''
|
||||||
|
Verify that closing a stream explicitly and killing the actor's
|
||||||
"root nursery" **before** the containing nursery tears down also
|
"root nursery" **before** the containing nursery tears down also
|
||||||
results in subactor(s) deregistering from the arbiter.
|
results in subactor(s) deregistering from the arbiter.
|
||||||
"""
|
|
||||||
|
'''
|
||||||
with pytest.raises(KeyboardInterrupt):
|
with pytest.raises(KeyboardInterrupt):
|
||||||
trio.run(
|
trio.run(
|
||||||
partial(
|
partial(
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,17 @@ import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import tractor
|
||||||
from tractor._testing import (
|
from tractor._testing import (
|
||||||
examples_dir,
|
examples_dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
|
_friggin_macos: bool = platform.system() == 'Darwin'
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def run_example_in_subproc(
|
def run_example_in_subproc(
|
||||||
|
|
@ -101,8 +106,10 @@ def run_example_in_subproc(
|
||||||
ids=lambda t: t[1],
|
ids=lambda t: t[1],
|
||||||
)
|
)
|
||||||
def test_example(
|
def test_example(
|
||||||
run_example_in_subproc,
|
run_example_in_subproc: Callable,
|
||||||
example_script,
|
example_script: str,
|
||||||
|
test_log: tractor.log.StackLevelAdapter,
|
||||||
|
ci_env: bool,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Load and run scripts from this repo's ``examples/`` dir as a user
|
Load and run scripts from this repo's ``examples/`` dir as a user
|
||||||
|
|
@ -116,9 +123,32 @@ def test_example(
|
||||||
'''
|
'''
|
||||||
ex_file: str = os.path.join(*example_script)
|
ex_file: str = os.path.join(*example_script)
|
||||||
|
|
||||||
if 'rpc_bidir_streaming' in ex_file and sys.version_info < (3, 9):
|
if (
|
||||||
|
'rpc_bidir_streaming' in ex_file
|
||||||
|
and
|
||||||
|
sys.version_info < (3, 9)
|
||||||
|
):
|
||||||
pytest.skip("2-way streaming example requires py3.9 async with syntax")
|
pytest.skip("2-way streaming example requires py3.9 async with syntax")
|
||||||
|
|
||||||
|
if (
|
||||||
|
'full_fledged_streaming_service' in ex_file
|
||||||
|
and
|
||||||
|
_friggin_macos
|
||||||
|
and
|
||||||
|
ci_env
|
||||||
|
):
|
||||||
|
pytest.skip(
|
||||||
|
'Streaming example is too flaky in CI\n'
|
||||||
|
'AND their competitor runs this CI service..\n'
|
||||||
|
'This test does run just fine "in person" however..'
|
||||||
|
)
|
||||||
|
|
||||||
|
timeout: float = (
|
||||||
|
60
|
||||||
|
if ci_env and _non_linux
|
||||||
|
else 16
|
||||||
|
)
|
||||||
|
|
||||||
with open(ex_file, 'r') as ex:
|
with open(ex_file, 'r') as ex:
|
||||||
code = ex.read()
|
code = ex.read()
|
||||||
|
|
||||||
|
|
@ -126,9 +156,12 @@ def test_example(
|
||||||
err = None
|
err = None
|
||||||
try:
|
try:
|
||||||
if not proc.poll():
|
if not proc.poll():
|
||||||
_, err = proc.communicate(timeout=15)
|
_, err = proc.communicate(timeout=timeout)
|
||||||
|
|
||||||
except subprocess.TimeoutExpired as e:
|
except subprocess.TimeoutExpired as e:
|
||||||
|
test_log.exception(
|
||||||
|
f'Example failed to finish within {timeout}s ??\n'
|
||||||
|
)
|
||||||
proc.kill()
|
proc.kill()
|
||||||
err = e.stderr
|
err = e.stderr
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,11 @@ async def sleep_and_err(
|
||||||
|
|
||||||
# just signature placeholders for compat with
|
# just signature placeholders for compat with
|
||||||
# ``to_asyncio.open_channel_from()``
|
# ``to_asyncio.open_channel_from()``
|
||||||
to_trio: trio.MemorySendChannel|None = None,
|
chan: to_asyncio.LinkedTaskChannel|None = None,
|
||||||
from_trio: asyncio.Queue|None = None,
|
|
||||||
|
|
||||||
):
|
):
|
||||||
if to_trio:
|
if chan:
|
||||||
to_trio.send_nowait('start')
|
chan.started_nowait('start')
|
||||||
|
|
||||||
await asyncio.sleep(sleep_for)
|
await asyncio.sleep(sleep_for)
|
||||||
assert 0
|
assert 0
|
||||||
|
|
@ -238,7 +237,7 @@ async def trio_ctx(
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
tractor.to_asyncio.open_channel_from(
|
tractor.to_asyncio.open_channel_from(
|
||||||
sleep_and_err,
|
sleep_and_err,
|
||||||
) as (first, chan),
|
) as (chan, first),
|
||||||
):
|
):
|
||||||
|
|
||||||
assert first == 'start'
|
assert first == 'start'
|
||||||
|
|
@ -399,7 +398,7 @@ async def no_to_trio_in_args():
|
||||||
|
|
||||||
async def push_from_aio_task(
|
async def push_from_aio_task(
|
||||||
sequence: Iterable,
|
sequence: Iterable,
|
||||||
to_trio: trio.abc.SendChannel,
|
chan: to_asyncio.LinkedTaskChannel,
|
||||||
expect_cancel: False,
|
expect_cancel: False,
|
||||||
fail_early: bool,
|
fail_early: bool,
|
||||||
exit_early: bool,
|
exit_early: bool,
|
||||||
|
|
@ -407,15 +406,12 @@ async def push_from_aio_task(
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# print('trying breakpoint')
|
|
||||||
# breakpoint()
|
|
||||||
|
|
||||||
# sync caller ctx manager
|
# sync caller ctx manager
|
||||||
to_trio.send_nowait(True)
|
chan.started_nowait(True)
|
||||||
|
|
||||||
for i in sequence:
|
for i in sequence:
|
||||||
print(f'asyncio sending {i}')
|
print(f'asyncio sending {i}')
|
||||||
to_trio.send_nowait(i)
|
chan.send_nowait(i)
|
||||||
await asyncio.sleep(0.001)
|
await asyncio.sleep(0.001)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -478,7 +474,7 @@ async def stream_from_aio(
|
||||||
trio_exit_early
|
trio_exit_early
|
||||||
))
|
))
|
||||||
|
|
||||||
) as (first, chan):
|
) as (chan, first):
|
||||||
|
|
||||||
assert first is True
|
assert first is True
|
||||||
|
|
||||||
|
|
@ -732,15 +728,21 @@ def test_aio_errors_and_channel_propagates_and_closes(
|
||||||
|
|
||||||
|
|
||||||
async def aio_echo_server(
|
async def aio_echo_server(
|
||||||
to_trio: trio.MemorySendChannel,
|
chan: to_asyncio.LinkedTaskChannel,
|
||||||
from_trio: asyncio.Queue,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
|
'''
|
||||||
|
An IPC-msg "echo server" with msgs received and relayed by
|
||||||
|
a parent `trio.Task` into a child `asyncio.Task`
|
||||||
|
and then repeated back to that local parent (`trio.Task`)
|
||||||
|
and sent again back to the original calling remote actor.
|
||||||
|
|
||||||
to_trio.send_nowait('start')
|
'''
|
||||||
|
# same semantics as `trio.TaskStatus.started()`
|
||||||
|
chan.started_nowait('start')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
msg = await from_trio.get()
|
msg = await chan.get()
|
||||||
except to_asyncio.TrioTaskExited:
|
except to_asyncio.TrioTaskExited:
|
||||||
print(
|
print(
|
||||||
'breaking aio echo loop due to `trio` exit!'
|
'breaking aio echo loop due to `trio` exit!'
|
||||||
|
|
@ -748,7 +750,7 @@ async def aio_echo_server(
|
||||||
break
|
break
|
||||||
|
|
||||||
# echo the msg back
|
# echo the msg back
|
||||||
to_trio.send_nowait(msg)
|
chan.send_nowait(msg)
|
||||||
|
|
||||||
# if we get the terminate sentinel
|
# if we get the terminate sentinel
|
||||||
# break the echo loop
|
# break the echo loop
|
||||||
|
|
@ -765,7 +767,10 @@ async def trio_to_aio_echo_server(
|
||||||
):
|
):
|
||||||
async with to_asyncio.open_channel_from(
|
async with to_asyncio.open_channel_from(
|
||||||
aio_echo_server,
|
aio_echo_server,
|
||||||
) as (first, chan):
|
) as (
|
||||||
|
chan,
|
||||||
|
first, # value from `chan.started_nowait()` above
|
||||||
|
):
|
||||||
assert first == 'start'
|
assert first == 'start'
|
||||||
|
|
||||||
await ctx.started(first)
|
await ctx.started(first)
|
||||||
|
|
@ -776,7 +781,8 @@ async def trio_to_aio_echo_server(
|
||||||
await chan.send(msg)
|
await chan.send(msg)
|
||||||
|
|
||||||
out = await chan.receive()
|
out = await chan.receive()
|
||||||
# echo back to parent actor-task
|
|
||||||
|
# echo back to parent-actor's remote parent-ctx-task!
|
||||||
await stream.send(out)
|
await stream.send(out)
|
||||||
|
|
||||||
if out is None:
|
if out is None:
|
||||||
|
|
@ -1090,24 +1096,21 @@ def test_sigint_closes_lifetime_stack(
|
||||||
|
|
||||||
|
|
||||||
# ?TODO asyncio.Task fn-deco?
|
# ?TODO asyncio.Task fn-deco?
|
||||||
# -[ ] do sig checkingat import time like @context?
|
|
||||||
# -[ ] maybe name it @aio_task ??
|
|
||||||
# -[ ] chan: to_asyncio.InterloopChannel ??
|
# -[ ] chan: to_asyncio.InterloopChannel ??
|
||||||
|
# -[ ] do fn-sig checking at import time like @context?
|
||||||
|
# |_[ ] maybe name it @a(sync)io_task ??
|
||||||
|
# @asyncio_task <- not bad ??
|
||||||
async def raise_before_started(
|
async def raise_before_started(
|
||||||
# from_trio: asyncio.Queue,
|
|
||||||
# to_trio: trio.abc.SendChannel,
|
|
||||||
chan: to_asyncio.LinkedTaskChannel,
|
chan: to_asyncio.LinkedTaskChannel,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
`asyncio.Task` entry point which RTEs before calling
|
`asyncio.Task` entry point which RTEs before calling
|
||||||
`to_trio.send_nowait()`.
|
`chan.started_nowait()`.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
raise RuntimeError('Some shite went wrong before `.send_nowait()`!!')
|
raise RuntimeError('Some shite went wrong before `.send_nowait()`!!')
|
||||||
|
|
||||||
# to_trio.send_nowait('Uhh we shouldve RTE-d ^^ ??')
|
|
||||||
chan.started_nowait('Uhh we shouldve RTE-d ^^ ??')
|
chan.started_nowait('Uhh we shouldve RTE-d ^^ ??')
|
||||||
await asyncio.sleep(float('inf'))
|
await asyncio.sleep(float('inf'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -581,7 +581,7 @@ def test_peer_canceller(
|
||||||
assert (
|
assert (
|
||||||
re.canceller
|
re.canceller
|
||||||
==
|
==
|
||||||
root.uid
|
root.aid.uid
|
||||||
)
|
)
|
||||||
|
|
||||||
else: # the other 2 ctxs
|
else: # the other 2 ctxs
|
||||||
|
|
@ -590,7 +590,7 @@ def test_peer_canceller(
|
||||||
and (
|
and (
|
||||||
re.canceller
|
re.canceller
|
||||||
==
|
==
|
||||||
canceller.channel.uid
|
canceller.channel.aid.uid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -745,7 +745,7 @@ def test_peer_canceller(
|
||||||
# -> each context should have received
|
# -> each context should have received
|
||||||
# a silently absorbed context cancellation
|
# a silently absorbed context cancellation
|
||||||
# in its remote nursery scope.
|
# in its remote nursery scope.
|
||||||
# assert ctx.chan.uid == ctx.canceller
|
# assert ctx.chan.aid.uid == ctx.canceller
|
||||||
|
|
||||||
# NOTE: when an inter-peer cancellation
|
# NOTE: when an inter-peer cancellation
|
||||||
# occurred, we DO NOT expect this
|
# occurred, we DO NOT expect this
|
||||||
|
|
@ -802,7 +802,7 @@ async def basic_echo_server(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
actor: Actor = tractor.current_actor()
|
actor: Actor = tractor.current_actor()
|
||||||
uid: tuple = actor.uid
|
uid: tuple = actor.aid.uid
|
||||||
await ctx.started(uid)
|
await ctx.started(uid)
|
||||||
async with ctx.open_stream() as ipc:
|
async with ctx.open_stream() as ipc:
|
||||||
async for msg in ipc:
|
async for msg in ipc:
|
||||||
|
|
@ -857,7 +857,7 @@ async def serve_subactors(
|
||||||
f'|_{peer}\n'
|
f'|_{peer}\n'
|
||||||
)
|
)
|
||||||
await ipc.send((
|
await ipc.send((
|
||||||
peer.chan.uid,
|
peer.chan.aid.uid,
|
||||||
peer.chan.raddr.unwrap(),
|
peer.chan.raddr.unwrap(),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
@ -992,7 +992,7 @@ async def tell_little_bro(
|
||||||
sub_ctx.open_stream() as echo_ipc,
|
sub_ctx.open_stream() as echo_ipc,
|
||||||
):
|
):
|
||||||
actor: Actor = current_actor()
|
actor: Actor = current_actor()
|
||||||
uid: tuple = actor.uid
|
uid: tuple = actor.aid.uid
|
||||||
for i in range(rng_seed):
|
for i in range(rng_seed):
|
||||||
msg: tuple = (
|
msg: tuple = (
|
||||||
uid,
|
uid,
|
||||||
|
|
@ -1097,7 +1097,7 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
) as (client_ctx, client_says),
|
) as (client_ctx, client_says),
|
||||||
):
|
):
|
||||||
root: Actor = current_actor()
|
root: Actor = current_actor()
|
||||||
spawner_uid: tuple = spawn_ctx.chan.uid
|
spawner_uid: tuple = spawn_ctx.chan.aid.uid
|
||||||
print(
|
print(
|
||||||
f'Server says: {first}\n'
|
f'Server says: {first}\n'
|
||||||
f'Client says: {client_says}\n'
|
f'Client says: {client_says}\n'
|
||||||
|
|
@ -1116,7 +1116,7 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
print(
|
print(
|
||||||
'Sub-spawn came online\n'
|
'Sub-spawn came online\n'
|
||||||
f'portal: {sub}\n'
|
f'portal: {sub}\n'
|
||||||
f'.uid: {sub.actor.uid}\n'
|
f'.uid: {sub.actor.aid.uid}\n'
|
||||||
f'chan.raddr: {sub.chan.raddr}\n'
|
f'chan.raddr: {sub.chan.raddr}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1150,7 +1150,7 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
|
|
||||||
assert isinstance(res, ContextCancelled)
|
assert isinstance(res, ContextCancelled)
|
||||||
assert client_ctx.cancel_acked
|
assert client_ctx.cancel_acked
|
||||||
assert res.canceller == root.uid
|
assert res.canceller == root.aid.uid
|
||||||
assert not raise_sub_spawn_error_after
|
assert not raise_sub_spawn_error_after
|
||||||
|
|
||||||
# cancelling the spawner sub should
|
# cancelling the spawner sub should
|
||||||
|
|
@ -1184,8 +1184,8 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
# little_bro: a `RuntimeError`.
|
# little_bro: a `RuntimeError`.
|
||||||
#
|
#
|
||||||
check_inner_rte(rae)
|
check_inner_rte(rae)
|
||||||
assert rae.relay_uid == client.chan.uid
|
assert rae.relay_uid == client.chan.aid.uid
|
||||||
assert rae.src_uid == sub.chan.uid
|
assert rae.src_uid == sub.chan.aid.uid
|
||||||
|
|
||||||
assert not client_ctx.cancel_acked
|
assert not client_ctx.cancel_acked
|
||||||
assert (
|
assert (
|
||||||
|
|
@ -1214,12 +1214,12 @@ def test_peer_spawns_and_cancels_service_subactor(
|
||||||
except ContextCancelled as ctxc:
|
except ContextCancelled as ctxc:
|
||||||
_ctxc = ctxc
|
_ctxc = ctxc
|
||||||
print(
|
print(
|
||||||
f'{root.uid} caught ctxc from ctx with {client_ctx.chan.uid}\n'
|
f'{root.aid.uid} caught ctxc from ctx with {client_ctx.chan.aid.uid}\n'
|
||||||
f'{repr(ctxc)}\n'
|
f'{repr(ctxc)}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
if not raise_sub_spawn_error_after:
|
if not raise_sub_spawn_error_after:
|
||||||
assert ctxc.canceller == root.uid
|
assert ctxc.canceller == root.aid.uid
|
||||||
else:
|
else:
|
||||||
assert ctxc.canceller == spawner_uid
|
assert ctxc.canceller == spawner_uid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
"""
|
"""
|
||||||
Streaming via async gen api
|
Streaming via the, now legacy, "async-gen API".
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import platform
|
import platform
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
import tractor
|
import tractor
|
||||||
|
|
@ -19,7 +21,11 @@ def test_must_define_ctx():
|
||||||
async def no_ctx():
|
async def no_ctx():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert "no_ctx must be `ctx: tractor.Context" in str(err.value)
|
assert (
|
||||||
|
"no_ctx must be `ctx: tractor.Context"
|
||||||
|
in
|
||||||
|
str(err.value)
|
||||||
|
)
|
||||||
|
|
||||||
@tractor.stream
|
@tractor.stream
|
||||||
async def has_ctx(ctx):
|
async def has_ctx(ctx):
|
||||||
|
|
@ -69,14 +75,14 @@ async def stream_from_single_subactor(
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
registry_addrs=[reg_addr],
|
registry_addrs=[reg_addr],
|
||||||
start_method=start_method,
|
start_method=start_method,
|
||||||
) as nursery:
|
) as an:
|
||||||
|
|
||||||
async with tractor.find_actor('streamerd') as portals:
|
async with tractor.find_actor('streamerd') as portals:
|
||||||
|
|
||||||
if not portals:
|
if not portals:
|
||||||
|
|
||||||
# no brokerd actor found
|
# no brokerd actor found
|
||||||
portal = await nursery.start_actor(
|
portal = await an.start_actor(
|
||||||
'streamerd',
|
'streamerd',
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
|
|
@ -116,11 +122,22 @@ async def stream_from_single_subactor(
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'stream_func', [async_gen_stream, context_stream]
|
'stream_func',
|
||||||
|
[
|
||||||
|
async_gen_stream,
|
||||||
|
context_stream,
|
||||||
|
],
|
||||||
|
ids='stream_func={}'.format
|
||||||
)
|
)
|
||||||
def test_stream_from_single_subactor(reg_addr, start_method, stream_func):
|
def test_stream_from_single_subactor(
|
||||||
"""Verify streaming from a spawned async generator.
|
reg_addr: tuple,
|
||||||
"""
|
start_method: str,
|
||||||
|
stream_func: Callable,
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Verify streaming from a spawned async generator.
|
||||||
|
|
||||||
|
'''
|
||||||
trio.run(
|
trio.run(
|
||||||
partial(
|
partial(
|
||||||
stream_from_single_subactor,
|
stream_from_single_subactor,
|
||||||
|
|
@ -132,10 +149,9 @@ def test_stream_from_single_subactor(reg_addr, start_method, stream_func):
|
||||||
|
|
||||||
|
|
||||||
# this is the first 2 actors, streamer_1 and streamer_2
|
# this is the first 2 actors, streamer_1 and streamer_2
|
||||||
async def stream_data(seed):
|
async def stream_data(seed: int):
|
||||||
|
|
||||||
for i in range(seed):
|
for i in range(seed):
|
||||||
|
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
# trigger scheduler to simulate practical usage
|
# trigger scheduler to simulate practical usage
|
||||||
|
|
@ -143,15 +159,17 @@ async def stream_data(seed):
|
||||||
|
|
||||||
|
|
||||||
# this is the third actor; the aggregator
|
# this is the third actor; the aggregator
|
||||||
async def aggregate(seed):
|
async def aggregate(seed: int):
|
||||||
"""Ensure that the two streams we receive match but only stream
|
'''
|
||||||
|
Ensure that the two streams we receive match but only stream
|
||||||
a single set of values to the parent.
|
a single set of values to the parent.
|
||||||
"""
|
|
||||||
async with tractor.open_nursery() as nursery:
|
'''
|
||||||
|
async with tractor.open_nursery() as an:
|
||||||
portals = []
|
portals = []
|
||||||
for i in range(1, 3):
|
for i in range(1, 3):
|
||||||
# fork point
|
# fork point
|
||||||
portal = await nursery.start_actor(
|
portal = await an.start_actor(
|
||||||
name=f'streamer_{i}',
|
name=f'streamer_{i}',
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
|
|
@ -164,20 +182,28 @@ async def aggregate(seed):
|
||||||
async with send_chan:
|
async with send_chan:
|
||||||
|
|
||||||
async with portal.open_stream_from(
|
async with portal.open_stream_from(
|
||||||
stream_data, seed=seed,
|
stream_data,
|
||||||
|
seed=seed,
|
||||||
) as stream:
|
) as stream:
|
||||||
|
|
||||||
async for value in stream:
|
async for value in stream:
|
||||||
# leverage trio's built-in backpressure
|
# leverage trio's built-in backpressure
|
||||||
await send_chan.send(value)
|
await send_chan.send(value)
|
||||||
|
|
||||||
print(f"FINISHED ITERATING {portal.channel.uid}")
|
print(
|
||||||
|
f'FINISHED ITERATING!\n'
|
||||||
|
f'peer: {portal.channel.aid.uid}'
|
||||||
|
)
|
||||||
|
|
||||||
# spawn 2 trio tasks to collect streams and push to a local queue
|
# spawn 2 trio tasks to collect streams and push to a local queue
|
||||||
async with trio.open_nursery() as n:
|
async with trio.open_nursery() as tn:
|
||||||
|
|
||||||
for portal in portals:
|
for portal in portals:
|
||||||
n.start_soon(push_to_chan, portal, send_chan.clone())
|
tn.start_soon(
|
||||||
|
push_to_chan,
|
||||||
|
portal,
|
||||||
|
send_chan.clone(),
|
||||||
|
)
|
||||||
|
|
||||||
# close this local task's reference to send side
|
# close this local task's reference to send side
|
||||||
await send_chan.aclose()
|
await send_chan.aclose()
|
||||||
|
|
@ -194,20 +220,21 @@ async def aggregate(seed):
|
||||||
|
|
||||||
print("FINISHED ITERATING in aggregator")
|
print("FINISHED ITERATING in aggregator")
|
||||||
|
|
||||||
await nursery.cancel()
|
await an.cancel()
|
||||||
print("WAITING on `ActorNursery` to finish")
|
print("WAITING on `ActorNursery` to finish")
|
||||||
print("AGGREGATOR COMPLETE!")
|
print("AGGREGATOR COMPLETE!")
|
||||||
|
|
||||||
|
|
||||||
# this is the main actor and *arbiter*
|
async def a_quadruple_example() -> list[int]:
|
||||||
async def a_quadruple_example():
|
'''
|
||||||
# a nursery which spawns "actors"
|
Open the root-actor which is also a "registrar".
|
||||||
async with tractor.open_nursery() as nursery:
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
async with tractor.open_nursery() as an:
|
||||||
seed = int(1e3)
|
seed = int(1e3)
|
||||||
pre_start = time.time()
|
pre_start = time.time()
|
||||||
|
|
||||||
portal = await nursery.start_actor(
|
portal = await an.start_actor(
|
||||||
name='aggregator',
|
name='aggregator',
|
||||||
enable_modules=[__name__],
|
enable_modules=[__name__],
|
||||||
)
|
)
|
||||||
|
|
@ -228,8 +255,14 @@ async def a_quadruple_example():
|
||||||
return result_stream
|
return result_stream
|
||||||
|
|
||||||
|
|
||||||
async def cancel_after(wait, reg_addr):
|
async def cancel_after(
|
||||||
async with tractor.open_root_actor(registry_addrs=[reg_addr]):
|
wait: float,
|
||||||
|
reg_addr: tuple,
|
||||||
|
) -> list[int]:
|
||||||
|
|
||||||
|
async with tractor.open_root_actor(
|
||||||
|
registry_addrs=[reg_addr],
|
||||||
|
):
|
||||||
with trio.move_on_after(wait):
|
with trio.move_on_after(wait):
|
||||||
return await a_quadruple_example()
|
return await a_quadruple_example()
|
||||||
|
|
||||||
|
|
@ -240,6 +273,10 @@ def time_quad_ex(
|
||||||
ci_env: bool,
|
ci_env: bool,
|
||||||
spawn_backend: str,
|
spawn_backend: str,
|
||||||
):
|
):
|
||||||
|
non_linux: bool = (_sys := platform.system()) != 'Linux'
|
||||||
|
if ci_env and non_linux:
|
||||||
|
pytest.skip(f'Test is too flaky on {_sys!r} in CI')
|
||||||
|
|
||||||
if spawn_backend == 'mp':
|
if spawn_backend == 'mp':
|
||||||
'''
|
'''
|
||||||
no idea but the mp *nix runs are flaking out here often...
|
no idea but the mp *nix runs are flaking out here often...
|
||||||
|
|
@ -247,16 +284,20 @@ def time_quad_ex(
|
||||||
'''
|
'''
|
||||||
pytest.skip("Test is too flaky on mp in CI")
|
pytest.skip("Test is too flaky on mp in CI")
|
||||||
|
|
||||||
timeout = 7 if platform.system() in ('Windows', 'Darwin') else 4
|
timeout = 7 if non_linux else 4
|
||||||
start = time.time()
|
start = time.time()
|
||||||
results = trio.run(cancel_after, timeout, reg_addr)
|
results: list[int] = trio.run(
|
||||||
diff = time.time() - start
|
cancel_after,
|
||||||
|
timeout,
|
||||||
|
reg_addr,
|
||||||
|
)
|
||||||
|
diff: float = time.time() - start
|
||||||
assert results
|
assert results
|
||||||
return results, diff
|
return results, diff
|
||||||
|
|
||||||
|
|
||||||
def test_a_quadruple_example(
|
def test_a_quadruple_example(
|
||||||
time_quad_ex: tuple,
|
time_quad_ex: tuple[list[int], float],
|
||||||
ci_env: bool,
|
ci_env: bool,
|
||||||
spawn_backend: str,
|
spawn_backend: str,
|
||||||
):
|
):
|
||||||
|
|
@ -264,13 +305,12 @@ def test_a_quadruple_example(
|
||||||
This also serves as a kind of "we'd like to be this fast test".
|
This also serves as a kind of "we'd like to be this fast test".
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
non_linux: bool = (_sys := platform.system()) != 'Linux'
|
||||||
|
|
||||||
results, diff = time_quad_ex
|
results, diff = time_quad_ex
|
||||||
assert results
|
assert results
|
||||||
this_fast = (
|
this_fast = (
|
||||||
6 if platform.system() in (
|
6 if non_linux
|
||||||
'Windows',
|
|
||||||
'Darwin',
|
|
||||||
)
|
|
||||||
else 3
|
else 3
|
||||||
)
|
)
|
||||||
assert diff < this_fast
|
assert diff < this_fast
|
||||||
|
|
@ -281,19 +321,33 @@ def test_a_quadruple_example(
|
||||||
list(map(lambda i: i/10, range(3, 9)))
|
list(map(lambda i: i/10, range(3, 9)))
|
||||||
)
|
)
|
||||||
def test_not_fast_enough_quad(
|
def test_not_fast_enough_quad(
|
||||||
reg_addr, time_quad_ex, cancel_delay, ci_env, spawn_backend
|
reg_addr: tuple,
|
||||||
|
time_quad_ex: tuple[list[int], float],
|
||||||
|
cancel_delay: float,
|
||||||
|
ci_env: bool,
|
||||||
|
spawn_backend: str,
|
||||||
):
|
):
|
||||||
"""Verify we can cancel midway through the quad example and all actors
|
'''
|
||||||
cancel gracefully.
|
Verify we can cancel midway through the quad example and all
|
||||||
"""
|
actors cancel gracefully.
|
||||||
|
|
||||||
|
'''
|
||||||
results, diff = time_quad_ex
|
results, diff = time_quad_ex
|
||||||
delay = max(diff - cancel_delay, 0)
|
delay = max(diff - cancel_delay, 0)
|
||||||
results = trio.run(cancel_after, delay, reg_addr)
|
results = trio.run(
|
||||||
system = platform.system()
|
cancel_after,
|
||||||
if system in ('Windows', 'Darwin') and results is not None:
|
delay,
|
||||||
|
reg_addr,
|
||||||
|
)
|
||||||
|
system: str = platform.system()
|
||||||
|
if (
|
||||||
|
system in ('Windows', 'Darwin')
|
||||||
|
and
|
||||||
|
results is not None
|
||||||
|
):
|
||||||
# In CI envoirments it seems later runs are quicker then the first
|
# In CI envoirments it seems later runs are quicker then the first
|
||||||
# so just ignore these
|
# so just ignore these
|
||||||
print(f"Woa there {system} caught your breath eh?")
|
print(f'Woa there {system} caught your breath eh?')
|
||||||
else:
|
else:
|
||||||
# should be cancelled mid-streaming
|
# should be cancelled mid-streaming
|
||||||
assert results is None
|
assert results is None
|
||||||
|
|
@ -301,23 +355,24 @@ def test_not_fast_enough_quad(
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_respawn_consumer_task(
|
async def test_respawn_consumer_task(
|
||||||
reg_addr,
|
reg_addr: tuple,
|
||||||
spawn_backend,
|
spawn_backend: str,
|
||||||
loglevel,
|
loglevel: str,
|
||||||
):
|
):
|
||||||
"""Verify that ``._portal.ReceiveStream.shield()``
|
'''
|
||||||
|
Verify that ``._portal.ReceiveStream.shield()``
|
||||||
sucessfully protects the underlying IPC channel from being closed
|
sucessfully protects the underlying IPC channel from being closed
|
||||||
when cancelling and respawning a consumer task.
|
when cancelling and respawning a consumer task.
|
||||||
|
|
||||||
This also serves to verify that all values from the stream can be
|
This also serves to verify that all values from the stream can be
|
||||||
received despite the respawns.
|
received despite the respawns.
|
||||||
|
|
||||||
"""
|
'''
|
||||||
stream = None
|
stream = None
|
||||||
|
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery() as an:
|
||||||
|
|
||||||
portal = await n.start_actor(
|
portal = await an.start_actor(
|
||||||
name='streamer',
|
name='streamer',
|
||||||
enable_modules=[__name__]
|
enable_modules=[__name__]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ if TYPE_CHECKING:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_non_linux: bool = platform.system() != 'Linux'
|
||||||
|
|
||||||
|
|
||||||
def test_abort_on_sigint(
|
def test_abort_on_sigint(
|
||||||
daemon: subprocess.Popen,
|
daemon: subprocess.Popen,
|
||||||
):
|
):
|
||||||
|
|
@ -137,6 +140,7 @@ def test_non_registrar_spawns_child(
|
||||||
reg_addr: UnwrappedAddress,
|
reg_addr: UnwrappedAddress,
|
||||||
loglevel: str,
|
loglevel: str,
|
||||||
debug_mode: bool,
|
debug_mode: bool,
|
||||||
|
ci_env: bool,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Ensure a non-regristar (serving) root actor can spawn a sub and
|
Ensure a non-regristar (serving) root actor can spawn a sub and
|
||||||
|
|
@ -148,6 +152,12 @@ def test_non_registrar_spawns_child(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async def main():
|
async def main():
|
||||||
|
|
||||||
|
# XXX, since apparently on macos in GH's CI it can be a race
|
||||||
|
# with the `daemon` registrar on grabbing the socket-addr..
|
||||||
|
if ci_env and _non_linux:
|
||||||
|
await trio.sleep(.5)
|
||||||
|
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
registry_addrs=[reg_addr],
|
registry_addrs=[reg_addr],
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ def test_infected_root_actor(
|
||||||
),
|
),
|
||||||
to_asyncio.open_channel_from(
|
to_asyncio.open_channel_from(
|
||||||
aio_echo_server,
|
aio_echo_server,
|
||||||
) as (first, chan),
|
) as (chan, first),
|
||||||
):
|
):
|
||||||
assert first == 'start'
|
assert first == 'start'
|
||||||
|
|
||||||
|
|
@ -91,13 +91,12 @@ def test_infected_root_actor(
|
||||||
async def sync_and_err(
|
async def sync_and_err(
|
||||||
# just signature placeholders for compat with
|
# just signature placeholders for compat with
|
||||||
# ``to_asyncio.open_channel_from()``
|
# ``to_asyncio.open_channel_from()``
|
||||||
to_trio: trio.MemorySendChannel,
|
chan: tractor.to_asyncio.LinkedTaskChannel,
|
||||||
from_trio: asyncio.Queue,
|
|
||||||
ev: asyncio.Event,
|
ev: asyncio.Event,
|
||||||
|
|
||||||
):
|
):
|
||||||
if to_trio:
|
if chan:
|
||||||
to_trio.send_nowait('start')
|
chan.started_nowait('start')
|
||||||
|
|
||||||
await ev.wait()
|
await ev.wait()
|
||||||
raise RuntimeError('asyncio-side')
|
raise RuntimeError('asyncio-side')
|
||||||
|
|
@ -174,7 +173,7 @@ def test_trio_prestarted_task_bubbles(
|
||||||
sync_and_err,
|
sync_and_err,
|
||||||
ev=aio_ev,
|
ev=aio_ev,
|
||||||
)
|
)
|
||||||
) as (first, chan),
|
) as (chan, first),
|
||||||
):
|
):
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ def unlink_file():
|
||||||
async def crash_and_clean_tmpdir(
|
async def crash_and_clean_tmpdir(
|
||||||
tmp_file_path: str,
|
tmp_file_path: str,
|
||||||
error: bool = True,
|
error: bool = True,
|
||||||
|
rent_cancel: bool = True,
|
||||||
|
|
||||||
|
# XXX unused, but do we really need to test these cases?
|
||||||
|
self_cancel: bool = False,
|
||||||
):
|
):
|
||||||
global _file_path
|
global _file_path
|
||||||
_file_path = tmp_file_path
|
_file_path = tmp_file_path
|
||||||
|
|
@ -32,43 +36,75 @@ async def crash_and_clean_tmpdir(
|
||||||
assert os.path.isfile(tmp_file_path)
|
assert os.path.isfile(tmp_file_path)
|
||||||
await trio.sleep(0.1)
|
await trio.sleep(0.1)
|
||||||
if error:
|
if error:
|
||||||
|
print('erroring in subactor!')
|
||||||
assert 0
|
assert 0
|
||||||
else:
|
|
||||||
|
elif self_cancel:
|
||||||
|
print('SELF-cancelling subactor!')
|
||||||
actor.cancel_soon()
|
actor.cancel_soon()
|
||||||
|
|
||||||
|
elif rent_cancel:
|
||||||
|
await trio.sleep_forever()
|
||||||
|
|
||||||
|
print('subactor exiting task!')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'error_in_child',
|
'error_in_child',
|
||||||
[True, False],
|
[True, False],
|
||||||
|
ids='error_in_child={}'.format,
|
||||||
)
|
)
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_lifetime_stack_wipes_tmpfile(
|
async def test_lifetime_stack_wipes_tmpfile(
|
||||||
tmp_path,
|
tmp_path,
|
||||||
error_in_child: bool,
|
error_in_child: bool,
|
||||||
|
loglevel: str,
|
||||||
|
# log: tractor.log.StackLevelAdapter,
|
||||||
|
# ^TODO, once landed via macos support!
|
||||||
):
|
):
|
||||||
child_tmp_file = tmp_path / "child.txt"
|
child_tmp_file = tmp_path / "child.txt"
|
||||||
child_tmp_file.touch()
|
child_tmp_file.touch()
|
||||||
assert child_tmp_file.exists()
|
assert child_tmp_file.exists()
|
||||||
path = str(child_tmp_file)
|
path = str(child_tmp_file)
|
||||||
|
|
||||||
|
# NOTE, this is expected to cancel the sub
|
||||||
|
# in the `error_in_child=False` case!
|
||||||
|
timeout: float = (
|
||||||
|
1.6 if error_in_child
|
||||||
|
else 1
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
with trio.move_on_after(0.5):
|
with trio.move_on_after(timeout) as cs:
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery(
|
||||||
await ( # inlined portal
|
loglevel=loglevel,
|
||||||
await n.run_in_actor(
|
) as an:
|
||||||
crash_and_clean_tmpdir,
|
await ( # inlined `tractor.Portal`
|
||||||
tmp_file_path=path,
|
await an.run_in_actor(
|
||||||
error=error_in_child,
|
crash_and_clean_tmpdir,
|
||||||
)
|
tmp_file_path=path,
|
||||||
).result()
|
error=error_in_child,
|
||||||
|
)
|
||||||
|
).result()
|
||||||
except (
|
except (
|
||||||
tractor.RemoteActorError,
|
tractor.RemoteActorError,
|
||||||
# tractor.BaseExceptionGroup,
|
|
||||||
BaseExceptionGroup,
|
BaseExceptionGroup,
|
||||||
):
|
) as _exc:
|
||||||
pass
|
exc = _exc
|
||||||
|
from tractor.log import get_console_log
|
||||||
|
log = get_console_log(
|
||||||
|
level=loglevel,
|
||||||
|
name=__name__,
|
||||||
|
)
|
||||||
|
log.exception(
|
||||||
|
f'Subactor failed as expected with {type(exc)!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
# tmp file should have been wiped by
|
# tmp file should have been wiped by
|
||||||
# teardown stack.
|
# teardown stack.
|
||||||
assert not child_tmp_file.exists()
|
assert not child_tmp_file.exists()
|
||||||
|
|
||||||
|
if error_in_child:
|
||||||
|
assert not cs.cancel_called
|
||||||
|
else:
|
||||||
|
# expect timeout in some cases?
|
||||||
|
assert cs.cancel_called
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
Shared mem primitives and APIs.
|
Shared mem primitives and APIs.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import platform
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
# import numpy
|
# import numpy
|
||||||
|
|
@ -53,7 +54,18 @@ def test_child_attaches_alot():
|
||||||
shm_key=shml.key,
|
shm_key=shml.key,
|
||||||
) as (ctx, start_val),
|
) as (ctx, start_val),
|
||||||
):
|
):
|
||||||
assert start_val == key
|
assert (_key := shml.key) == start_val
|
||||||
|
|
||||||
|
if platform.system() != 'Darwin':
|
||||||
|
# XXX, macOS has a char limit..
|
||||||
|
# see `ipc._shm._shorten_key_for_macos`
|
||||||
|
assert (
|
||||||
|
start_val
|
||||||
|
==
|
||||||
|
key
|
||||||
|
==
|
||||||
|
_key
|
||||||
|
)
|
||||||
await ctx.result()
|
await ctx.result()
|
||||||
|
|
||||||
await portal.cancel_actor()
|
await portal.cancel_actor()
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ async def open_actor_cluster(
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
tractor.trionics.maybe_raise_from_masking_exc()
|
tractor.trionics.maybe_raise_from_masking_exc()
|
||||||
):
|
):
|
||||||
uid = tractor.current_actor().uid
|
uid = tractor.current_actor().aid.uid
|
||||||
|
|
||||||
async def _start(name: str) -> None:
|
async def _start(name: str) -> None:
|
||||||
name = f'{uid[0]}.{name}'
|
name = f'{uid[0]}.{name}'
|
||||||
|
|
|
||||||
|
|
@ -463,10 +463,11 @@ class Context:
|
||||||
|
|
||||||
# self._cancel_called = val
|
# self._cancel_called = val
|
||||||
|
|
||||||
|
# TODO, use the `Actor.aid: Aid` instead!
|
||||||
@property
|
@property
|
||||||
def canceller(self) -> tuple[str, str]|None:
|
def canceller(self) -> tuple[str, str]|None:
|
||||||
'''
|
'''
|
||||||
`Actor.uid: tuple[str, str]` of the (remote)
|
`Actor.aid.uid: tuple[str, str]` of the (remote)
|
||||||
actor-process who's task was cancelled thus causing this
|
actor-process who's task was cancelled thus causing this
|
||||||
(side of the) context to also be cancelled.
|
(side of the) context to also be cancelled.
|
||||||
|
|
||||||
|
|
@ -499,12 +500,12 @@ class Context:
|
||||||
if from_uid := re.src_uid:
|
if from_uid := re.src_uid:
|
||||||
from_uid: tuple = tuple(from_uid)
|
from_uid: tuple = tuple(from_uid)
|
||||||
|
|
||||||
our_uid: tuple = self._actor.uid
|
our_uid: tuple = self._actor.aid.uid
|
||||||
our_canceller = self.canceller
|
our_canceller = self.canceller
|
||||||
|
|
||||||
return bool(
|
return bool(
|
||||||
isinstance((ctxc := re), ContextCancelled)
|
isinstance((ctxc := re), ContextCancelled)
|
||||||
and from_uid == self.chan.uid
|
and from_uid == self.chan.aid.uid
|
||||||
and ctxc.canceller == our_uid
|
and ctxc.canceller == our_uid
|
||||||
and our_canceller == our_uid
|
and our_canceller == our_uid
|
||||||
)
|
)
|
||||||
|
|
@ -515,7 +516,7 @@ class Context:
|
||||||
Records whether the task on the remote side of this IPC
|
Records whether the task on the remote side of this IPC
|
||||||
context acknowledged a cancel request via a relayed
|
context acknowledged a cancel request via a relayed
|
||||||
`ContextCancelled` with the `.canceller` attr set to the
|
`ContextCancelled` with the `.canceller` attr set to the
|
||||||
`Actor.uid` of the local actor who's task entered
|
`Actor.aid.uid` of the local actor who's task entered
|
||||||
`Portal.open_context()`.
|
`Portal.open_context()`.
|
||||||
|
|
||||||
This will only be `True` when `.cancel()` is called and
|
This will only be `True` when `.cancel()` is called and
|
||||||
|
|
@ -789,8 +790,8 @@ class Context:
|
||||||
# appropriately.
|
# appropriately.
|
||||||
log.runtime(
|
log.runtime(
|
||||||
'Setting remote error for ctx\n\n'
|
'Setting remote error for ctx\n\n'
|
||||||
f'<= {self.peer_side!r}: {self.chan.uid}\n'
|
f'<= {self.peer_side!r}: {self.chan.aid.reprol()}\n'
|
||||||
f'=> {self.side!r}: {self._actor.uid}\n\n'
|
f'=> {self.side!r}: {self._actor.aid.reprol()}\n\n'
|
||||||
f'{error!r}'
|
f'{error!r}'
|
||||||
)
|
)
|
||||||
self._remote_error: BaseException = error
|
self._remote_error: BaseException = error
|
||||||
|
|
@ -811,7 +812,7 @@ class Context:
|
||||||
# cancelled.
|
# cancelled.
|
||||||
#
|
#
|
||||||
# !TODO, switching to `Actor.aid` here!
|
# !TODO, switching to `Actor.aid` here!
|
||||||
if (canc := error.canceller) == self._actor.uid:
|
if (canc := error.canceller) == self._actor.aid.uid:
|
||||||
whom: str = 'us'
|
whom: str = 'us'
|
||||||
self._canceller = canc
|
self._canceller = canc
|
||||||
else:
|
else:
|
||||||
|
|
@ -1036,7 +1037,7 @@ class Context:
|
||||||
---------
|
---------
|
||||||
- after the far end cancels, the `.cancel()` calling side
|
- after the far end cancels, the `.cancel()` calling side
|
||||||
should receive a `ContextCancelled` with the
|
should receive a `ContextCancelled` with the
|
||||||
`.canceller: tuple` uid set to the current `Actor.uid`.
|
`.canceller: tuple` uid set to the current `Actor.aid.uid`.
|
||||||
|
|
||||||
- timeout (quickly) on failure to rx this ACK error-msg in
|
- timeout (quickly) on failure to rx this ACK error-msg in
|
||||||
an attempt to sidestep 2-generals when the transport
|
an attempt to sidestep 2-generals when the transport
|
||||||
|
|
@ -1065,9 +1066,9 @@ class Context:
|
||||||
)
|
)
|
||||||
reminfo: str = (
|
reminfo: str = (
|
||||||
# ' =>\n'
|
# ' =>\n'
|
||||||
# f'Context.cancel() => {self.chan.uid}\n'
|
# f'Context.cancel() => {self.chan.aid.uid}\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
f'c)=> {self.chan.uid}\n'
|
f'c)=> {self.chan.aid.reprol()}\n'
|
||||||
f' |_[{self.dst_maddr}\n'
|
f' |_[{self.dst_maddr}\n'
|
||||||
f' >> {self.repr_rpc}\n'
|
f' >> {self.repr_rpc}\n'
|
||||||
# f' >> {self._nsf}() -> {codec}[dict]:\n\n'
|
# f' >> {self._nsf}() -> {codec}[dict]:\n\n'
|
||||||
|
|
@ -1211,7 +1212,7 @@ class Context:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
__tracebackhide__: bool = hide_tb
|
__tracebackhide__: bool = hide_tb
|
||||||
peer_uid: tuple = self.chan.uid
|
peer_uid: tuple = self.chan.aid.uid
|
||||||
|
|
||||||
# XXX NOTE XXX: `ContextCancelled`/`StreamOverrun` absorption
|
# XXX NOTE XXX: `ContextCancelled`/`StreamOverrun` absorption
|
||||||
# for "graceful cancellation" case(s):
|
# for "graceful cancellation" case(s):
|
||||||
|
|
@ -1228,7 +1229,7 @@ class Context:
|
||||||
# (`ContextCancelled`) as an expected
|
# (`ContextCancelled`) as an expected
|
||||||
# error-msg-is-cancellation-ack IFF said
|
# error-msg-is-cancellation-ack IFF said
|
||||||
# `remote_error: ContextCancelled` has `.canceller`
|
# `remote_error: ContextCancelled` has `.canceller`
|
||||||
# set to the `Actor.uid` of THIS task (i.e. the
|
# set to the `Actor.aid.uid` of THIS task (i.e. the
|
||||||
# cancellation requesting task's actor is the actor
|
# cancellation requesting task's actor is the actor
|
||||||
# checking whether it should absorb the ctxc).
|
# checking whether it should absorb the ctxc).
|
||||||
self_ctxc: bool = self._is_self_cancelled(remote_error)
|
self_ctxc: bool = self._is_self_cancelled(remote_error)
|
||||||
|
|
@ -1679,7 +1680,7 @@ class Context:
|
||||||
|
|
||||||
elif self._started_called:
|
elif self._started_called:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f'called `.started()` twice on context with {self.chan.uid}'
|
f'called `.started()` twice on context with {self.chan.aid.uid}'
|
||||||
)
|
)
|
||||||
|
|
||||||
started_msg = Started(
|
started_msg = Started(
|
||||||
|
|
@ -1812,7 +1813,7 @@ class Context:
|
||||||
'''
|
'''
|
||||||
cid: str = self.cid
|
cid: str = self.cid
|
||||||
chan: Channel = self.chan
|
chan: Channel = self.chan
|
||||||
from_uid: tuple[str, str] = chan.uid
|
from_uid: tuple[str, str] = chan.aid.uid
|
||||||
send_chan: trio.MemorySendChannel = self._send_chan
|
send_chan: trio.MemorySendChannel = self._send_chan
|
||||||
nsf: NamespacePath = self._nsf
|
nsf: NamespacePath = self._nsf
|
||||||
|
|
||||||
|
|
@ -1953,20 +1954,22 @@ class Context:
|
||||||
# overrun state and that msg isn't stuck in an
|
# overrun state and that msg isn't stuck in an
|
||||||
# overflow queue what happens?!?
|
# overflow queue what happens?!?
|
||||||
|
|
||||||
local_uid = self._actor.uid
|
local_aid = self._actor.aid
|
||||||
txt: str = (
|
txt: str = (
|
||||||
'on IPC context:\n'
|
'on IPC context:\n'
|
||||||
|
|
||||||
f'<= sender: {from_uid}\n'
|
f'<= sender: {from_uid}\n'
|
||||||
f' |_ {self._nsf}()\n\n'
|
f' |_ {self._nsf}()\n\n'
|
||||||
|
|
||||||
f'=> overrun: {local_uid}\n'
|
f'=> overrun: {local_aid.reprol()!r}\n'
|
||||||
f' |_cid: {cid}\n'
|
f' |_cid: {cid}\n'
|
||||||
f' |_task: {self._task}\n'
|
f' |_task: {self._task}\n'
|
||||||
)
|
)
|
||||||
if not self._stream_opened:
|
if not self._stream_opened:
|
||||||
txt += (
|
txt += (
|
||||||
f'\n*** No stream open on `{local_uid[0]}` side! ***\n\n'
|
f'\n'
|
||||||
|
f'*** No stream open on `{local_aid.name}` side! ***\n'
|
||||||
|
f'\n'
|
||||||
f'{msg}\n'
|
f'{msg}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -2115,7 +2118,11 @@ async def open_context_from_portal(
|
||||||
# XXX NOTE XXX: currenly we do NOT allow opening a contex
|
# XXX NOTE XXX: currenly we do NOT allow opening a contex
|
||||||
# with "self" since the local feeder mem-chan processing
|
# with "self" since the local feeder mem-chan processing
|
||||||
# is not built for it.
|
# is not built for it.
|
||||||
if (uid := portal.channel.uid) == portal.actor.uid:
|
if (
|
||||||
|
(uid := portal.channel.aid.uid)
|
||||||
|
==
|
||||||
|
portal.actor.aid.uid
|
||||||
|
):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
'** !! Invalid Operation !! **\n'
|
'** !! Invalid Operation !! **\n'
|
||||||
'Can not open an IPC ctx with the local actor!\n'
|
'Can not open an IPC ctx with the local actor!\n'
|
||||||
|
|
@ -2329,7 +2336,7 @@ async def open_context_from_portal(
|
||||||
and
|
and
|
||||||
ctxc is ctx._remote_error
|
ctxc is ctx._remote_error
|
||||||
and
|
and
|
||||||
ctxc.canceller == portal.actor.uid
|
ctxc.canceller == portal.actor.aid.uid
|
||||||
):
|
):
|
||||||
log.cancel(
|
log.cancel(
|
||||||
f'Context (cid=[{ctx.cid[-6:]}..] cancelled gracefully with:\n'
|
f'Context (cid=[{ctx.cid[-6:]}..] cancelled gracefully with:\n'
|
||||||
|
|
@ -2406,7 +2413,7 @@ async def open_context_from_portal(
|
||||||
logmeth(msg)
|
logmeth(msg)
|
||||||
|
|
||||||
if debug_mode():
|
if debug_mode():
|
||||||
# async with debug.acquire_debug_lock(portal.actor.uid):
|
# async with debug.acquire_debug_lock(portal.actor.aid.uid):
|
||||||
# pass
|
# pass
|
||||||
# TODO: factor ^ into below for non-root cases?
|
# TODO: factor ^ into below for non-root cases?
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -982,6 +982,7 @@ class TransportClosed(Exception):
|
||||||
'''
|
'''
|
||||||
__tracebackhide__: bool = hide_tb
|
__tracebackhide__: bool = hide_tb
|
||||||
message: str = message or self.message
|
message: str = message or self.message
|
||||||
|
|
||||||
# when a cause is set, slap it onto the log emission.
|
# when a cause is set, slap it onto the log emission.
|
||||||
if cause := self.src_exc:
|
if cause := self.src_exc:
|
||||||
cause_tb_str: str = ''.join(
|
cause_tb_str: str = ''.join(
|
||||||
|
|
@ -989,7 +990,7 @@ class TransportClosed(Exception):
|
||||||
)
|
)
|
||||||
message += (
|
message += (
|
||||||
f'{cause_tb_str}\n' # tb
|
f'{cause_tb_str}\n' # tb
|
||||||
f' {cause}\n' # exc repr
|
f'{cause!r}\n' # exc repr
|
||||||
)
|
)
|
||||||
|
|
||||||
getattr(
|
getattr(
|
||||||
|
|
|
||||||
|
|
@ -252,8 +252,8 @@ async def _invoke_non_context(
|
||||||
):
|
):
|
||||||
log.warning(
|
log.warning(
|
||||||
'Failed to send RPC result?\n'
|
'Failed to send RPC result?\n'
|
||||||
f'|_{func}@{actor.uid}() -> {ret_msg}\n\n'
|
f'|_{func}@{actor.aid.reprol()}() -> {ret_msg}\n\n'
|
||||||
f'x=> peer: {chan.uid}\n'
|
f'x=> peer: {chan.aid.reprol()}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
@acm
|
@acm
|
||||||
|
|
@ -698,7 +698,7 @@ async def _invoke(
|
||||||
# which cancels the scope presuming the input error
|
# which cancels the scope presuming the input error
|
||||||
# is not a `.cancel_acked` pleaser.
|
# is not a `.cancel_acked` pleaser.
|
||||||
if rpc_ctx_cs.cancelled_caught:
|
if rpc_ctx_cs.cancelled_caught:
|
||||||
our_uid: tuple = actor.uid
|
our_uid: tuple = actor.aid.uid
|
||||||
|
|
||||||
# first check for and raise any remote error
|
# first check for and raise any remote error
|
||||||
# before raising any context cancelled case
|
# before raising any context cancelled case
|
||||||
|
|
@ -730,7 +730,7 @@ async def _invoke(
|
||||||
# TODO: determine if the ctx peer task was the
|
# TODO: determine if the ctx peer task was the
|
||||||
# exact task which cancelled, vs. some other
|
# exact task which cancelled, vs. some other
|
||||||
# task in the same actor.
|
# task in the same actor.
|
||||||
elif canceller == ctx.chan.uid:
|
elif canceller == ctx.chan.aid.uid:
|
||||||
explain += f'its {ctx.peer_side!r}-side peer'
|
explain += f'its {ctx.peer_side!r}-side peer'
|
||||||
|
|
||||||
elif canceller == our_uid:
|
elif canceller == our_uid:
|
||||||
|
|
@ -825,7 +825,7 @@ async def _invoke(
|
||||||
# associated child isn't in debug any more
|
# associated child isn't in debug any more
|
||||||
await debug.maybe_wait_for_debugger()
|
await debug.maybe_wait_for_debugger()
|
||||||
ctx: Context = actor._contexts.pop((
|
ctx: Context = actor._contexts.pop((
|
||||||
chan.uid,
|
chan.aid.uid,
|
||||||
cid,
|
cid,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
@ -927,7 +927,7 @@ async def try_ship_error_to_remote(
|
||||||
log.critical(
|
log.critical(
|
||||||
'IPC transport failure -> '
|
'IPC transport failure -> '
|
||||||
f'failed to ship error to {remote_descr}!\n\n'
|
f'failed to ship error to {remote_descr}!\n\n'
|
||||||
f'{type(msg)!r}[{msg.boxed_type_str}] X=> {channel.uid}\n'
|
f'{type(msg)!r}[{msg.boxed_type_str}] X=> {channel.aid.uid}\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
# TODO: use `.msg.preetty_struct` for this!
|
# TODO: use `.msg.preetty_struct` for this!
|
||||||
f'{msg}\n'
|
f'{msg}\n'
|
||||||
|
|
@ -1005,7 +1005,7 @@ async def process_messages(
|
||||||
async for msg in chan:
|
async for msg in chan:
|
||||||
log.transport( # type: ignore
|
log.transport( # type: ignore
|
||||||
f'IPC msg from peer\n'
|
f'IPC msg from peer\n'
|
||||||
f'<= {chan.uid}\n\n'
|
f'<= {chan.aid.reprol()}\n\n'
|
||||||
|
|
||||||
# TODO: use of the pprinting of structs is
|
# TODO: use of the pprinting of structs is
|
||||||
# FRAGILE and should prolly not be
|
# FRAGILE and should prolly not be
|
||||||
|
|
@ -1109,7 +1109,7 @@ async def process_messages(
|
||||||
except BaseException:
|
except BaseException:
|
||||||
log.exception(
|
log.exception(
|
||||||
'Failed to cancel task?\n'
|
'Failed to cancel task?\n'
|
||||||
f'<= canceller: {chan.uid}\n'
|
f'<= canceller: {chan.aid.reprol()}\n'
|
||||||
f' |_{chan}\n\n'
|
f' |_{chan}\n\n'
|
||||||
f'=> {actor}\n'
|
f'=> {actor}\n'
|
||||||
f' |_cid: {target_cid}\n'
|
f' |_cid: {target_cid}\n'
|
||||||
|
|
@ -1264,7 +1264,7 @@ async def process_messages(
|
||||||
|
|
||||||
log.transport(
|
log.transport(
|
||||||
'Waiting on next IPC msg from\n'
|
'Waiting on next IPC msg from\n'
|
||||||
f'peer: {chan.uid}\n'
|
f'peer: {chan.aid.reprol()}\n'
|
||||||
f'|_{chan}\n'
|
f'|_{chan}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1313,12 +1313,10 @@ async def process_messages(
|
||||||
f'peer IPC channel closed abruptly?\n'
|
f'peer IPC channel closed abruptly?\n'
|
||||||
f'\n'
|
f'\n'
|
||||||
f'<=x[\n'
|
f'<=x[\n'
|
||||||
f' {chan}\n'
|
f'{chan}\n'
|
||||||
f' |_{chan.raddr}\n\n'
|
|
||||||
)
|
)
|
||||||
+
|
+
|
||||||
tc.message
|
tc.message
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# transport **WAS** disconnected
|
# transport **WAS** disconnected
|
||||||
|
|
@ -1341,8 +1339,8 @@ async def process_messages(
|
||||||
match err:
|
match err:
|
||||||
case ContextCancelled():
|
case ContextCancelled():
|
||||||
log.cancel(
|
log.cancel(
|
||||||
f'Actor: {actor.uid} was context-cancelled with,\n'
|
f'Actor: {actor.aid.reprol()!r} is ctxc with,\n'
|
||||||
f'str(err)'
|
f'{str(err)}'
|
||||||
)
|
)
|
||||||
case _:
|
case _:
|
||||||
log.exception("Actor errored:")
|
log.exception("Actor errored:")
|
||||||
|
|
|
||||||
|
|
@ -691,7 +691,7 @@ class Actor:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# ?TODO, use Aid here as well?
|
# ?TODO, use Aid here as well?
|
||||||
actor_uid = chan.uid
|
actor_uid = chan.aid.uid
|
||||||
assert actor_uid
|
assert actor_uid
|
||||||
try:
|
try:
|
||||||
ctx = self._contexts[(
|
ctx = self._contexts[(
|
||||||
|
|
@ -701,7 +701,7 @@ class Actor:
|
||||||
)]
|
)]
|
||||||
log.debug(
|
log.debug(
|
||||||
f'Retreived cached IPC ctx for\n'
|
f'Retreived cached IPC ctx for\n'
|
||||||
f'peer: {chan.uid}\n'
|
f'peer: {chan.aid.uid}\n'
|
||||||
f'cid:{cid}\n'
|
f'cid:{cid}\n'
|
||||||
)
|
)
|
||||||
ctx._allow_overruns: bool = allow_overruns
|
ctx._allow_overruns: bool = allow_overruns
|
||||||
|
|
@ -718,7 +718,7 @@ class Actor:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.debug(
|
log.debug(
|
||||||
f'Allocate new IPC ctx for\n'
|
f'Allocate new IPC ctx for\n'
|
||||||
f'peer: {chan.uid}\n'
|
f'peer: {chan.aid.uid}\n'
|
||||||
f'cid: {cid}\n'
|
f'cid: {cid}\n'
|
||||||
)
|
)
|
||||||
ctx = mk_context(
|
ctx = mk_context(
|
||||||
|
|
@ -764,7 +764,7 @@ class Actor:
|
||||||
|
|
||||||
'''
|
'''
|
||||||
cid: str = str(uuid.uuid4())
|
cid: str = str(uuid.uuid4())
|
||||||
assert chan.uid
|
assert chan.aid.uid
|
||||||
ctx = self.get_context(
|
ctx = self.get_context(
|
||||||
chan=chan,
|
chan=chan,
|
||||||
cid=cid,
|
cid=cid,
|
||||||
|
|
@ -791,12 +791,12 @@ class Actor:
|
||||||
ns=ns,
|
ns=ns,
|
||||||
func=func,
|
func=func,
|
||||||
kwargs=kwargs,
|
kwargs=kwargs,
|
||||||
uid=self.uid,
|
uid=self.aid.uid, # <- !TODO use .aid!
|
||||||
cid=cid,
|
cid=cid,
|
||||||
)
|
)
|
||||||
log.runtime(
|
log.runtime(
|
||||||
'Sending RPC `Start`\n\n'
|
'Sending RPC `Start`\n\n'
|
||||||
f'=> peer: {chan.uid}\n'
|
f'=> peer: {chan.aid.uid}\n'
|
||||||
f' |_ {ns}.{func}({kwargs})\n\n'
|
f' |_ {ns}.{func}({kwargs})\n\n'
|
||||||
|
|
||||||
f'{pretty_struct.pformat(msg)}'
|
f'{pretty_struct.pformat(msg)}'
|
||||||
|
|
@ -1244,7 +1244,7 @@ class Actor:
|
||||||
'Cancel request for invalid RPC task.\n'
|
'Cancel request for invalid RPC task.\n'
|
||||||
'The task likely already completed or was never started!\n\n'
|
'The task likely already completed or was never started!\n\n'
|
||||||
f'<= canceller: {requesting_aid}\n'
|
f'<= canceller: {requesting_aid}\n'
|
||||||
f'=> {cid}@{parent_chan.uid}\n'
|
f'=> {cid}@{parent_chan.aid.uid}\n'
|
||||||
f' |_{parent_chan}\n'
|
f' |_{parent_chan}\n'
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
@ -1381,7 +1381,7 @@ class Actor:
|
||||||
f'Cancelling {descr} RPC tasks\n\n'
|
f'Cancelling {descr} RPC tasks\n\n'
|
||||||
f'<=c) {req_aid} [canceller]\n'
|
f'<=c) {req_aid} [canceller]\n'
|
||||||
f'{rent_chan_repr}'
|
f'{rent_chan_repr}'
|
||||||
f'c)=> {self.uid} [cancellee]\n'
|
f'c)=> {self.aid.uid} [cancellee]\n'
|
||||||
f' |_{self} [with {len(tasks)} tasks]\n'
|
f' |_{self} [with {len(tasks)} tasks]\n'
|
||||||
# f' |_tasks: {len(tasks)}\n'
|
# f' |_tasks: {len(tasks)}\n'
|
||||||
# f'{tasks_str}'
|
# f'{tasks_str}'
|
||||||
|
|
@ -1687,7 +1687,7 @@ async def async_main(
|
||||||
await reg_portal.run_from_ns(
|
await reg_portal.run_from_ns(
|
||||||
'self',
|
'self',
|
||||||
'register_actor',
|
'register_actor',
|
||||||
uid=actor.uid,
|
uid=actor.aid.uid,
|
||||||
addr=accept_addr.unwrap(),
|
addr=accept_addr.unwrap(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1758,9 +1758,11 @@ async def async_main(
|
||||||
# always!
|
# always!
|
||||||
match internal_err:
|
match internal_err:
|
||||||
case ContextCancelled():
|
case ContextCancelled():
|
||||||
|
reprol: str = actor.aid.reprol()
|
||||||
log.cancel(
|
log.cancel(
|
||||||
f'Actor: {actor.uid} was task-context-cancelled with,\n'
|
f'Actor {reprol!r} was task-ctx-cancelled with,\n'
|
||||||
f'str(internal_err)'
|
f'\n'
|
||||||
|
f'{internal_err!r}'
|
||||||
)
|
)
|
||||||
case _:
|
case _:
|
||||||
log.exception(
|
log.exception(
|
||||||
|
|
@ -1832,7 +1834,7 @@ async def async_main(
|
||||||
await reg_portal.run_from_ns(
|
await reg_portal.run_from_ns(
|
||||||
'self',
|
'self',
|
||||||
'unregister_actor',
|
'unregister_actor',
|
||||||
uid=actor.uid
|
uid=actor.aid.uid,
|
||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
failed = True
|
failed = True
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ async def exhaust_portal(
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
try:
|
try:
|
||||||
log.debug(
|
log.debug(
|
||||||
f'Waiting on final result from {actor.uid}'
|
f'Waiting on final result from {actor.aid.uid}'
|
||||||
)
|
)
|
||||||
|
|
||||||
# XXX: streams should never be reaped here since they should
|
# XXX: streams should never be reaped here since they should
|
||||||
|
|
@ -210,17 +210,17 @@ async def cancel_on_completion(
|
||||||
actor,
|
actor,
|
||||||
)
|
)
|
||||||
if isinstance(result, Exception):
|
if isinstance(result, Exception):
|
||||||
errors[actor.uid]: Exception = result
|
errors[actor.aid.uid]: Exception = result
|
||||||
log.cancel(
|
log.cancel(
|
||||||
'Cancelling subactor runtime due to error:\n\n'
|
'Cancelling subactor runtime due to error:\n\n'
|
||||||
f'Portal.cancel_actor() => {portal.channel.uid}\n\n'
|
f'Portal.cancel_actor() => {portal.channel.aid}\n\n'
|
||||||
f'error: {result}\n'
|
f'error: {result}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.runtime(
|
log.runtime(
|
||||||
'Cancelling subactor gracefully:\n\n'
|
'Cancelling subactor gracefully:\n\n'
|
||||||
f'Portal.cancel_actor() => {portal.channel.uid}\n\n'
|
f'Portal.cancel_actor() => {portal.channel.aid}\n\n'
|
||||||
f'result: {result}\n'
|
f'result: {result}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -308,7 +308,7 @@ async def hard_kill(
|
||||||
# )
|
# )
|
||||||
# with trio.CancelScope(shield=True):
|
# with trio.CancelScope(shield=True):
|
||||||
# async with debug.acquire_debug_lock(
|
# async with debug.acquire_debug_lock(
|
||||||
# subactor_uid=current_actor().uid,
|
# subactor_uid=current_actor().aid.uid,
|
||||||
# ) as _ctx:
|
# ) as _ctx:
|
||||||
# log.warning(
|
# log.warning(
|
||||||
# 'Acquired debug lock, child ready to be killed ??\n'
|
# 'Acquired debug lock, child ready to be killed ??\n'
|
||||||
|
|
@ -483,7 +483,7 @@ async def trio_proc(
|
||||||
# TODO, how to pass this over "wire" encodings like
|
# TODO, how to pass this over "wire" encodings like
|
||||||
# cmdline args?
|
# cmdline args?
|
||||||
# -[ ] maybe we can add an `msgtypes.Aid.min_tuple()` ?
|
# -[ ] maybe we can add an `msgtypes.Aid.min_tuple()` ?
|
||||||
str(subactor.uid),
|
str(subactor.aid.uid),
|
||||||
# Address the child must connect to on startup
|
# Address the child must connect to on startup
|
||||||
"--parent_addr",
|
"--parent_addr",
|
||||||
str(parent_addr)
|
str(parent_addr)
|
||||||
|
|
@ -514,7 +514,7 @@ async def trio_proc(
|
||||||
# channel should have handshake completed by the
|
# channel should have handshake completed by the
|
||||||
# local actor by the time we get a ref to it
|
# local actor by the time we get a ref to it
|
||||||
event, chan = await ipc_server.wait_for_peer(
|
event, chan = await ipc_server.wait_for_peer(
|
||||||
subactor.uid
|
subactor.aid.uid
|
||||||
)
|
)
|
||||||
|
|
||||||
except trio.Cancelled:
|
except trio.Cancelled:
|
||||||
|
|
@ -528,7 +528,9 @@ async def trio_proc(
|
||||||
await debug.maybe_wait_for_debugger()
|
await debug.maybe_wait_for_debugger()
|
||||||
|
|
||||||
elif proc is not None:
|
elif proc is not None:
|
||||||
async with debug.acquire_debug_lock(subactor.uid):
|
async with debug.acquire_debug_lock(
|
||||||
|
subactor_uid=subactor.aid.uid
|
||||||
|
):
|
||||||
# soft wait on the proc to terminate
|
# soft wait on the proc to terminate
|
||||||
with trio.move_on_after(0.5):
|
with trio.move_on_after(0.5):
|
||||||
await proc.wait()
|
await proc.wait()
|
||||||
|
|
@ -538,7 +540,7 @@ async def trio_proc(
|
||||||
assert proc
|
assert proc
|
||||||
|
|
||||||
portal = Portal(chan)
|
portal = Portal(chan)
|
||||||
actor_nursery._children[subactor.uid] = (
|
actor_nursery._children[subactor.aid.uid] = (
|
||||||
subactor,
|
subactor,
|
||||||
proc,
|
proc,
|
||||||
portal,
|
portal,
|
||||||
|
|
@ -563,7 +565,7 @@ async def trio_proc(
|
||||||
|
|
||||||
# track subactor in current nursery
|
# track subactor in current nursery
|
||||||
curr_actor: Actor = current_actor()
|
curr_actor: Actor = current_actor()
|
||||||
curr_actor._actoruid2nursery[subactor.uid] = actor_nursery
|
curr_actor._actoruid2nursery[subactor.aid.uid] = actor_nursery
|
||||||
|
|
||||||
# resume caller at next checkpoint now that child is up
|
# resume caller at next checkpoint now that child is up
|
||||||
task_status.started(portal)
|
task_status.started(portal)
|
||||||
|
|
@ -616,7 +618,9 @@ async def trio_proc(
|
||||||
# don't clobber an ongoing pdb
|
# don't clobber an ongoing pdb
|
||||||
if cancelled_during_spawn:
|
if cancelled_during_spawn:
|
||||||
# Try again to avoid TTY clobbering.
|
# Try again to avoid TTY clobbering.
|
||||||
async with debug.acquire_debug_lock(subactor.uid):
|
async with debug.acquire_debug_lock(
|
||||||
|
subactor_uid=subactor.aid.uid
|
||||||
|
):
|
||||||
with trio.move_on_after(0.5):
|
with trio.move_on_after(0.5):
|
||||||
await proc.wait()
|
await proc.wait()
|
||||||
|
|
||||||
|
|
@ -662,7 +666,7 @@ async def trio_proc(
|
||||||
if not cancelled_during_spawn:
|
if not cancelled_during_spawn:
|
||||||
# pop child entry to indicate we no longer managing this
|
# pop child entry to indicate we no longer managing this
|
||||||
# subactor
|
# subactor
|
||||||
actor_nursery._children.pop(subactor.uid)
|
actor_nursery._children.pop(subactor.aid.uid)
|
||||||
|
|
||||||
|
|
||||||
async def mp_proc(
|
async def mp_proc(
|
||||||
|
|
@ -744,7 +748,7 @@ async def mp_proc(
|
||||||
# register the process before start in case we get a cancel
|
# register the process before start in case we get a cancel
|
||||||
# request before the actor has fully spawned - then we can wait
|
# request before the actor has fully spawned - then we can wait
|
||||||
# for it to fully come up before sending a cancel request
|
# for it to fully come up before sending a cancel request
|
||||||
actor_nursery._children[subactor.uid] = (subactor, proc, None)
|
actor_nursery._children[subactor.aid.uid] = (subactor, proc, None)
|
||||||
|
|
||||||
proc.start()
|
proc.start()
|
||||||
if not proc.is_alive():
|
if not proc.is_alive():
|
||||||
|
|
@ -758,7 +762,7 @@ async def mp_proc(
|
||||||
# channel should have handshake completed by the
|
# channel should have handshake completed by the
|
||||||
# local actor by the time we get a ref to it
|
# local actor by the time we get a ref to it
|
||||||
event, chan = await ipc_server.wait_for_peer(
|
event, chan = await ipc_server.wait_for_peer(
|
||||||
subactor.uid,
|
subactor.aid.uid,
|
||||||
)
|
)
|
||||||
|
|
||||||
# XXX: monkey patch poll API to match the ``subprocess`` API..
|
# XXX: monkey patch poll API to match the ``subprocess`` API..
|
||||||
|
|
@ -771,7 +775,7 @@ async def mp_proc(
|
||||||
# any process we may have started.
|
# any process we may have started.
|
||||||
|
|
||||||
portal = Portal(chan)
|
portal = Portal(chan)
|
||||||
actor_nursery._children[subactor.uid] = (subactor, proc, portal)
|
actor_nursery._children[subactor.aid.uid] = (subactor, proc, portal)
|
||||||
|
|
||||||
# unblock parent task
|
# unblock parent task
|
||||||
task_status.started(portal)
|
task_status.started(portal)
|
||||||
|
|
@ -810,7 +814,7 @@ async def mp_proc(
|
||||||
# tandem if not done already
|
# tandem if not done already
|
||||||
log.warning(
|
log.warning(
|
||||||
"Cancelling existing result waiter task for "
|
"Cancelling existing result waiter task for "
|
||||||
f"{subactor.uid}")
|
f"{subactor.aid.uid}")
|
||||||
nursery.cancel_scope.cancel()
|
nursery.cancel_scope.cancel()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -828,7 +832,7 @@ async def mp_proc(
|
||||||
log.debug(f"Joined {proc}")
|
log.debug(f"Joined {proc}")
|
||||||
|
|
||||||
# pop child entry to indicate we are no longer managing subactor
|
# pop child entry to indicate we are no longer managing subactor
|
||||||
actor_nursery._children.pop(subactor.uid)
|
actor_nursery._children.pop(subactor.aid.uid)
|
||||||
|
|
||||||
# TODO: prolly report to ``mypy`` how this causes all sorts of
|
# TODO: prolly report to ``mypy`` how this causes all sorts of
|
||||||
# false errors..
|
# false errors..
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ from __future__ import annotations
|
||||||
from contextvars import (
|
from contextvars import (
|
||||||
ContextVar,
|
ContextVar,
|
||||||
)
|
)
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
|
@ -30,6 +29,7 @@ from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import platformdirs
|
||||||
from trio.lowlevel import current_task
|
from trio.lowlevel import current_task
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
@ -104,7 +104,7 @@ def current_actor(
|
||||||
msg += (
|
msg += (
|
||||||
f'Apparently the lact active actor was\n'
|
f'Apparently the lact active actor was\n'
|
||||||
f'|_{last}\n'
|
f'|_{last}\n'
|
||||||
f'|_{last.uid}\n'
|
f'|_{last.aid.uid}\n'
|
||||||
)
|
)
|
||||||
# no actor runtime has (as of yet) ever been started for
|
# no actor runtime has (as of yet) ever been started for
|
||||||
# this process.
|
# this process.
|
||||||
|
|
@ -172,23 +172,56 @@ def current_ipc_ctx(
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
# std ODE (mutable) app state location
|
|
||||||
_rtdir: Path = Path(os.environ['XDG_RUNTIME_DIR'])
|
|
||||||
|
|
||||||
|
|
||||||
def get_rt_dir(
|
def get_rt_dir(
|
||||||
subdir: str = 'tractor'
|
subdir: str|Path|None = None,
|
||||||
|
appname: str = 'tractor',
|
||||||
) -> Path:
|
) -> Path:
|
||||||
'''
|
'''
|
||||||
Return the user "runtime dir" where most userspace apps stick
|
Return the user "runtime dir", the file-sys location where most
|
||||||
their IPC and cache related system util-files; we take hold
|
userspace apps stick their IPC and cache related system
|
||||||
of a `'XDG_RUNTIME_DIR'/tractor/` subdir by default.
|
util-files.
|
||||||
|
|
||||||
|
On linux we use a `${XDG_RUNTIME_DIR}/tractor/` subdir by
|
||||||
|
default, but equivalents are mapped for each platform using
|
||||||
|
the lovely `platformdirs` lib.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
rtdir: Path = _rtdir / subdir
|
rt_dir: Path = Path(
|
||||||
if not rtdir.is_dir():
|
platformdirs.user_runtime_dir(
|
||||||
rtdir.mkdir()
|
appname=appname,
|
||||||
return rtdir
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Normalize and validate that `subdir` is a relative path
|
||||||
|
# without any parent-directory ("..") components, to prevent
|
||||||
|
# escaping the runtime directory.
|
||||||
|
if subdir:
|
||||||
|
subdir_path = (
|
||||||
|
subdir
|
||||||
|
if isinstance(subdir, Path)
|
||||||
|
else Path(subdir)
|
||||||
|
)
|
||||||
|
if subdir_path.is_absolute():
|
||||||
|
raise ValueError(
|
||||||
|
f'`subdir` must be a relative path!\n'
|
||||||
|
f'{subdir!r}\n'
|
||||||
|
)
|
||||||
|
if any(part == '..' for part in subdir_path.parts):
|
||||||
|
raise ValueError(
|
||||||
|
"`subdir` must not contain '..' components!\n"
|
||||||
|
f'{subdir!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
rt_dir: Path = rt_dir / subdir_path
|
||||||
|
|
||||||
|
if not rt_dir.is_dir():
|
||||||
|
rt_dir.mkdir(
|
||||||
|
parents=True,
|
||||||
|
exist_ok=True, # avoid `FileExistsError` from conc calls
|
||||||
|
)
|
||||||
|
|
||||||
|
return rt_dir
|
||||||
|
|
||||||
|
|
||||||
def current_ipc_protos() -> list[str]:
|
def current_ipc_protos() -> list[str]:
|
||||||
|
|
|
||||||
|
|
@ -391,15 +391,17 @@ class ActorNursery:
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if portal is None: # actor hasn't fully spawned yet
|
if portal is None: # actor hasn't fully spawned yet
|
||||||
event: trio.Event = server._peer_connected[subactor.uid]
|
event: trio.Event = server._peer_connected[
|
||||||
|
subactor.aid.uid
|
||||||
|
]
|
||||||
log.warning(
|
log.warning(
|
||||||
f"{subactor.uid} never 't finished spawning?"
|
f"{subactor.aid.uid} never 't finished spawning?"
|
||||||
)
|
)
|
||||||
|
|
||||||
await event.wait()
|
await event.wait()
|
||||||
|
|
||||||
# channel/portal should now be up
|
# channel/portal should now be up
|
||||||
_, _, portal = children[subactor.uid]
|
_, _, portal = children[subactor.aid.uid]
|
||||||
|
|
||||||
# XXX should be impossible to get here
|
# XXX should be impossible to get here
|
||||||
# unless method was called from within
|
# unless method was called from within
|
||||||
|
|
@ -407,7 +409,7 @@ class ActorNursery:
|
||||||
if portal is None:
|
if portal is None:
|
||||||
# cancelled while waiting on the event
|
# cancelled while waiting on the event
|
||||||
# to arrive
|
# to arrive
|
||||||
chan = server._peers[subactor.uid][-1]
|
chan = server._peers[subactor.aid.uid][-1]
|
||||||
if chan:
|
if chan:
|
||||||
portal = Portal(chan)
|
portal = Portal(chan)
|
||||||
else: # there's no other choice left
|
else: # there's no other choice left
|
||||||
|
|
@ -506,7 +508,7 @@ async def _open_and_supervise_one_cancels_all_nursery(
|
||||||
|
|
||||||
except BaseException as _inner_err:
|
except BaseException as _inner_err:
|
||||||
inner_err = _inner_err
|
inner_err = _inner_err
|
||||||
errors[actor.uid] = inner_err
|
errors[actor.aid.uid] = inner_err
|
||||||
|
|
||||||
# If we error in the root but the debugger is
|
# If we error in the root but the debugger is
|
||||||
# engaged we don't want to prematurely kill (and
|
# engaged we don't want to prematurely kill (and
|
||||||
|
|
@ -539,7 +541,7 @@ async def _open_and_supervise_one_cancels_all_nursery(
|
||||||
log.cancel(
|
log.cancel(
|
||||||
f'Actor-nursery cancelled by {etype}\n\n'
|
f'Actor-nursery cancelled by {etype}\n\n'
|
||||||
|
|
||||||
f'{current_actor().uid}\n'
|
f'{current_actor().aid.uid}\n'
|
||||||
f' |_{an}\n\n'
|
f' |_{an}\n\n'
|
||||||
|
|
||||||
# TODO: show tb str?
|
# TODO: show tb str?
|
||||||
|
|
@ -630,7 +632,7 @@ async def _open_and_supervise_one_cancels_all_nursery(
|
||||||
|
|
||||||
# show frame on any (likely) internal error
|
# show frame on any (likely) internal error
|
||||||
if (
|
if (
|
||||||
not an.cancelled
|
not an.cancel_called
|
||||||
and an._scope_error
|
and an._scope_error
|
||||||
):
|
):
|
||||||
__tracebackhide__: bool = False
|
__tracebackhide__: bool = False
|
||||||
|
|
@ -726,7 +728,7 @@ async def open_nursery(
|
||||||
if (
|
if (
|
||||||
an
|
an
|
||||||
and
|
and
|
||||||
not an.cancelled
|
not an.cancel_called
|
||||||
and
|
and
|
||||||
an._scope_error
|
an._scope_error
|
||||||
):
|
):
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,11 @@ def get_rando_addr(
|
||||||
# NOTE, file-name uniqueness (no-collisions) will be based on
|
# NOTE, file-name uniqueness (no-collisions) will be based on
|
||||||
# the runtime-directory and root (pytest-proc's) pid.
|
# the runtime-directory and root (pytest-proc's) pid.
|
||||||
case 'uds':
|
case 'uds':
|
||||||
testrun_reg_addr = addr_type.get_random().unwrap()
|
from tractor.ipc._uds import UDSAddress
|
||||||
|
addr: UDSAddress = addr_type.get_random()
|
||||||
|
assert addr.is_valid
|
||||||
|
assert addr.sockpath.resolve()
|
||||||
|
testrun_reg_addr = addr.unwrap()
|
||||||
|
|
||||||
# XXX, as sanity it should never the same as the default for the
|
# XXX, as sanity it should never the same as the default for the
|
||||||
# host-singleton registry actor.
|
# host-singleton registry actor.
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ def tractor_test(fn):
|
||||||
reg_addr=None,
|
reg_addr=None,
|
||||||
start_method: str|None = None,
|
start_method: str|None = None,
|
||||||
debug_mode: bool = False,
|
debug_mode: bool = False,
|
||||||
|
tpt_proto: str|None=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
# __tracebackhide__ = True
|
# __tracebackhide__ = True
|
||||||
|
|
@ -102,6 +103,9 @@ def tractor_test(fn):
|
||||||
# set of subprocess spawning backends
|
# set of subprocess spawning backends
|
||||||
kwargs['debug_mode'] = debug_mode
|
kwargs['debug_mode'] = debug_mode
|
||||||
|
|
||||||
|
if 'tpt_proto' in inspect.signature(fn).parameters:
|
||||||
|
# set of subprocess spawning backends
|
||||||
|
kwargs['tpt_proto'] = tpt_proto
|
||||||
|
|
||||||
if kwargs:
|
if kwargs:
|
||||||
|
|
||||||
|
|
@ -177,6 +181,13 @@ def pytest_configure(config):
|
||||||
backend = config.option.spawn_backend
|
backend = config.option.spawn_backend
|
||||||
tractor._spawn.try_set_start_method(backend)
|
tractor._spawn.try_set_start_method(backend)
|
||||||
|
|
||||||
|
# register custom marks to avoid warnings see,
|
||||||
|
# https://docs.pytest.org/en/stable/how-to/writing_plugins.html#registering-custom-markers
|
||||||
|
config.addinivalue_line(
|
||||||
|
'markers',
|
||||||
|
'no_tpt(proto_key): test will (likely) not behave with tpt backend'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def debug_mode(request) -> bool:
|
def debug_mode(request) -> bool:
|
||||||
|
|
@ -225,13 +236,32 @@ def tpt_protos(request) -> list[str]:
|
||||||
autouse=True,
|
autouse=True,
|
||||||
)
|
)
|
||||||
def tpt_proto(
|
def tpt_proto(
|
||||||
|
request,
|
||||||
tpt_protos: list[str],
|
tpt_protos: list[str],
|
||||||
) -> str:
|
) -> str:
|
||||||
proto_key: str = tpt_protos[0]
|
proto_key: str = tpt_protos[0]
|
||||||
|
|
||||||
|
# ?TODO, but needs a fn-scoped tpt_proto fixture..
|
||||||
|
# @pytest.mark.no_tpt('uds')
|
||||||
|
# node = request.node
|
||||||
|
# markers = node.own_markers
|
||||||
|
# for mark in markers:
|
||||||
|
# if (
|
||||||
|
# mark.name == 'no_tpt'
|
||||||
|
# and
|
||||||
|
# proto_key in mark.args
|
||||||
|
# ):
|
||||||
|
# pytest.skip(
|
||||||
|
# f'Test {node} normally fails with '
|
||||||
|
# f'tpt-proto={proto_key!r}\n'
|
||||||
|
# )
|
||||||
|
|
||||||
from tractor import _state
|
from tractor import _state
|
||||||
if _state._def_tpt_proto != proto_key:
|
if _state._def_tpt_proto != proto_key:
|
||||||
_state._def_tpt_proto = proto_key
|
_state._def_tpt_proto = proto_key
|
||||||
|
_state._runtime_vars['_enable_tpts'] = [
|
||||||
|
proto_key,
|
||||||
|
]
|
||||||
|
|
||||||
yield proto_key
|
yield proto_key
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ cancellation during REPL interaction.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
import platform
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
)
|
)
|
||||||
|
|
@ -49,6 +50,7 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
log = get_logger()
|
log = get_logger()
|
||||||
|
|
||||||
|
_is_macos: bool = platform.system() == 'Darwin'
|
||||||
_ctlc_ignore_header: str = (
|
_ctlc_ignore_header: str = (
|
||||||
'Ignoring SIGINT while debug REPL in use'
|
'Ignoring SIGINT while debug REPL in use'
|
||||||
)
|
)
|
||||||
|
|
@ -300,6 +302,11 @@ def sigint_shield(
|
||||||
# XXX: yah, mega hack, but how else do we catch this madness XD
|
# XXX: yah, mega hack, but how else do we catch this madness XD
|
||||||
if (
|
if (
|
||||||
repl.shname == 'xonsh'
|
repl.shname == 'xonsh'
|
||||||
|
or (
|
||||||
|
repl.shname == 'bash'
|
||||||
|
and
|
||||||
|
_is_macos
|
||||||
|
)
|
||||||
):
|
):
|
||||||
flush_status += (
|
flush_status += (
|
||||||
'-> ALSO re-flushing due to `xonsh`..\n'
|
'-> ALSO re-flushing due to `xonsh`..\n'
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class Channel:
|
||||||
self._transport: MsgTransport|None = transport
|
self._transport: MsgTransport|None = transport
|
||||||
|
|
||||||
# set after handshake - always info from peer end
|
# set after handshake - always info from peer end
|
||||||
self.aid: Aid|None = None
|
self._aid: Aid|None = None
|
||||||
|
|
||||||
self._aiter_msgs = self._iter_msgs()
|
self._aiter_msgs = self._iter_msgs()
|
||||||
self._exc: Exception|None = None
|
self._exc: Exception|None = None
|
||||||
|
|
@ -122,6 +122,14 @@ class Channel:
|
||||||
'''
|
'''
|
||||||
return self._cancel_called
|
return self._cancel_called
|
||||||
|
|
||||||
|
@property
|
||||||
|
def aid(self) -> Aid:
|
||||||
|
'''
|
||||||
|
Peer actor's ID.
|
||||||
|
|
||||||
|
'''
|
||||||
|
return self._aid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def uid(self) -> tuple[str, str]:
|
def uid(self) -> tuple[str, str]:
|
||||||
'''
|
'''
|
||||||
|
|
@ -505,7 +513,7 @@ class Channel:
|
||||||
f'<= {peer_aid.reprol(sin_uuid=False)}\n'
|
f'<= {peer_aid.reprol(sin_uuid=False)}\n'
|
||||||
)
|
)
|
||||||
# NOTE, we always are referencing the remote peer!
|
# NOTE, we always are referencing the remote peer!
|
||||||
self.aid = peer_aid
|
self._aid = peer_aid
|
||||||
return peer_aid
|
return peer_aid
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ considered optional within the context of this runtime-library.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
import hashlib
|
||||||
from multiprocessing import shared_memory as shm
|
from multiprocessing import shared_memory as shm
|
||||||
from multiprocessing.shared_memory import (
|
from multiprocessing.shared_memory import (
|
||||||
# SharedMemory,
|
# SharedMemory,
|
||||||
|
|
@ -106,11 +107,12 @@ class NDToken(Struct, frozen=True):
|
||||||
This type is msg safe.
|
This type is msg safe.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
shm_name: str # this servers as a "key" value
|
shm_name: str # actual OS-level name (may be shortened on macOS)
|
||||||
shm_first_index_name: str
|
shm_first_index_name: str
|
||||||
shm_last_index_name: str
|
shm_last_index_name: str
|
||||||
dtype_descr: tuple
|
dtype_descr: tuple
|
||||||
size: int # in struct-array index / row terms
|
size: int # in struct-array index / row terms
|
||||||
|
key: str|None = None # original descriptive key (for lookup)
|
||||||
|
|
||||||
# TODO: use nptyping here on dtypes
|
# TODO: use nptyping here on dtypes
|
||||||
@property
|
@property
|
||||||
|
|
@ -124,6 +126,41 @@ class NDToken(Struct, frozen=True):
|
||||||
def as_msg(self):
|
def as_msg(self):
|
||||||
return to_builtins(self)
|
return to_builtins(self)
|
||||||
|
|
||||||
|
def __eq__(self, other) -> bool:
|
||||||
|
'''
|
||||||
|
Compare tokens based on shm names and dtype,
|
||||||
|
ignoring the `key` field.
|
||||||
|
|
||||||
|
The `key` field is only used for lookups,
|
||||||
|
not for token identity.
|
||||||
|
|
||||||
|
'''
|
||||||
|
if not isinstance(other, NDToken):
|
||||||
|
return False
|
||||||
|
return (
|
||||||
|
self.shm_name == other.shm_name
|
||||||
|
and self.shm_first_index_name
|
||||||
|
== other.shm_first_index_name
|
||||||
|
and self.shm_last_index_name
|
||||||
|
== other.shm_last_index_name
|
||||||
|
and self.dtype_descr == other.dtype_descr
|
||||||
|
and self.size == other.size
|
||||||
|
)
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
'''
|
||||||
|
Hash based on the same fields used
|
||||||
|
in `.__eq__()`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
return hash((
|
||||||
|
self.shm_name,
|
||||||
|
self.shm_first_index_name,
|
||||||
|
self.shm_last_index_name,
|
||||||
|
self.dtype_descr,
|
||||||
|
self.size,
|
||||||
|
))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_msg(cls, msg: dict) -> NDToken:
|
def from_msg(cls, msg: dict) -> NDToken:
|
||||||
if isinstance(msg, NDToken):
|
if isinstance(msg, NDToken):
|
||||||
|
|
@ -160,6 +197,50 @@ def get_shm_token(key: str) -> NDToken | None:
|
||||||
return _known_tokens.get(key)
|
return _known_tokens.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
def _shorten_key_for_macos(
|
||||||
|
key: str,
|
||||||
|
prefix: str = '',
|
||||||
|
suffix: str = '',
|
||||||
|
) -> str:
|
||||||
|
'''
|
||||||
|
MacOS has a (hillarious) 31 character limit for POSIX shared
|
||||||
|
memory names. Hash long keys to fit within this limit while
|
||||||
|
maintaining uniqueness.
|
||||||
|
|
||||||
|
'''
|
||||||
|
# macOS shm_open() has a 31 char limit (PSHMNAMLEN)
|
||||||
|
# format: /t_<hash16> = 19 chars, well under limit
|
||||||
|
max_len: int = 31
|
||||||
|
if len(key) <= max_len:
|
||||||
|
return key
|
||||||
|
|
||||||
|
_hash: str = hashlib.sha256(
|
||||||
|
key.encode()
|
||||||
|
).hexdigest()
|
||||||
|
|
||||||
|
hash_len: int = (
|
||||||
|
(max_len - 1)
|
||||||
|
- len(prefix)
|
||||||
|
- len(suffix)
|
||||||
|
)
|
||||||
|
key_hash: str = _hash[:hash_len]
|
||||||
|
short_key = (
|
||||||
|
prefix
|
||||||
|
+
|
||||||
|
f'{key_hash}'
|
||||||
|
+
|
||||||
|
suffix
|
||||||
|
)
|
||||||
|
|
||||||
|
log.debug(
|
||||||
|
f'Shortened shm key for macOS:\n'
|
||||||
|
f' original: {key!r} ({len(key)!r} chars)\n'
|
||||||
|
f' shortened: {short_key!r}'
|
||||||
|
f' ({len(short_key)!r} chars)'
|
||||||
|
)
|
||||||
|
return short_key
|
||||||
|
|
||||||
|
|
||||||
def _make_token(
|
def _make_token(
|
||||||
key: str,
|
key: str,
|
||||||
size: int,
|
size: int,
|
||||||
|
|
@ -171,12 +252,32 @@ def _make_token(
|
||||||
to access a shared array.
|
to access a shared array.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
# On macOS, shorten keys that exceed the
|
||||||
|
# 31 character limit
|
||||||
|
if platform.system() == 'Darwin':
|
||||||
|
shm_name = _shorten_key_for_macos(
|
||||||
|
key=key,
|
||||||
|
)
|
||||||
|
shm_first = _shorten_key_for_macos(
|
||||||
|
key=key,
|
||||||
|
suffix='_first',
|
||||||
|
)
|
||||||
|
shm_last = _shorten_key_for_macos(
|
||||||
|
key=key,
|
||||||
|
suffix='_last',
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
shm_name = key
|
||||||
|
shm_first = key + '_first'
|
||||||
|
shm_last = key + '_last'
|
||||||
|
|
||||||
return NDToken(
|
return NDToken(
|
||||||
shm_name=key,
|
shm_name=shm_name,
|
||||||
shm_first_index_name=key + "_first",
|
shm_first_index_name=shm_first,
|
||||||
shm_last_index_name=key + "_last",
|
shm_last_index_name=shm_last,
|
||||||
dtype_descr=tuple(np.dtype(dtype).descr),
|
dtype_descr=tuple(np.dtype(dtype).descr),
|
||||||
size=size,
|
size=size,
|
||||||
|
key=key, # store original key for lookup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -431,9 +532,17 @@ class ShmArray:
|
||||||
|
|
||||||
def destroy(self) -> None:
|
def destroy(self) -> None:
|
||||||
if _USE_POSIX:
|
if _USE_POSIX:
|
||||||
# We manually unlink to bypass all the "resource tracker"
|
# We manually unlink to bypass all the
|
||||||
# nonsense meant for non-SC systems.
|
# "resource tracker" nonsense meant for
|
||||||
shm_unlink(self._shm.name)
|
# non-SC systems.
|
||||||
|
name = self._shm.name
|
||||||
|
try:
|
||||||
|
shm_unlink(name)
|
||||||
|
except FileNotFoundError:
|
||||||
|
# might be a teardown race here?
|
||||||
|
log.warning(
|
||||||
|
f'Shm for {name} already unlinked?'
|
||||||
|
)
|
||||||
|
|
||||||
self._first.destroy()
|
self._first.destroy()
|
||||||
self._last.destroy()
|
self._last.destroy()
|
||||||
|
|
@ -463,8 +572,16 @@ def open_shm_ndarray(
|
||||||
a = np.zeros(size, dtype=dtype)
|
a = np.zeros(size, dtype=dtype)
|
||||||
a['index'] = np.arange(len(a))
|
a['index'] = np.arange(len(a))
|
||||||
|
|
||||||
|
# Create token first to get the (possibly
|
||||||
|
# shortened) shm name
|
||||||
|
token = _make_token(
|
||||||
|
key=key,
|
||||||
|
size=size,
|
||||||
|
dtype=dtype,
|
||||||
|
)
|
||||||
|
|
||||||
shm = SharedMemory(
|
shm = SharedMemory(
|
||||||
name=key,
|
name=token.shm_name,
|
||||||
create=True,
|
create=True,
|
||||||
size=a.nbytes
|
size=a.nbytes
|
||||||
)
|
)
|
||||||
|
|
@ -476,12 +593,6 @@ def open_shm_ndarray(
|
||||||
array[:] = a[:]
|
array[:] = a[:]
|
||||||
array.setflags(write=int(not readonly))
|
array.setflags(write=int(not readonly))
|
||||||
|
|
||||||
token = _make_token(
|
|
||||||
key=key,
|
|
||||||
size=size,
|
|
||||||
dtype=dtype,
|
|
||||||
)
|
|
||||||
|
|
||||||
# create single entry arrays for storing an first and last indices
|
# create single entry arrays for storing an first and last indices
|
||||||
first = SharedInt(
|
first = SharedInt(
|
||||||
shm=SharedMemory(
|
shm=SharedMemory(
|
||||||
|
|
@ -554,13 +665,23 @@ def attach_shm_ndarray(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
token = NDToken.from_msg(token)
|
token = NDToken.from_msg(token)
|
||||||
key = token.shm_name
|
# Use original key for _known_tokens lookup,
|
||||||
|
# shm_name for OS calls
|
||||||
|
lookup_key = (
|
||||||
|
token.key if token.key
|
||||||
|
else token.shm_name
|
||||||
|
)
|
||||||
|
|
||||||
if key in _known_tokens:
|
if lookup_key in _known_tokens:
|
||||||
assert NDToken.from_msg(_known_tokens[key]) == token, "WTF"
|
assert (
|
||||||
|
NDToken.from_msg(
|
||||||
|
_known_tokens[lookup_key]
|
||||||
|
) == token
|
||||||
|
), 'WTF'
|
||||||
|
|
||||||
# XXX: ugh, looks like due to the ``shm_open()`` C api we can't
|
# XXX: ugh, looks like due to the ``shm_open()``
|
||||||
# actually place files in a subdir, see discussion here:
|
# C api we can't actually place files in a subdir,
|
||||||
|
# see discussion here:
|
||||||
# https://stackoverflow.com/a/11103289
|
# https://stackoverflow.com/a/11103289
|
||||||
|
|
||||||
# attach to array buffer and view as per dtype
|
# attach to array buffer and view as per dtype
|
||||||
|
|
@ -568,7 +689,7 @@ def attach_shm_ndarray(
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
try:
|
try:
|
||||||
shm = SharedMemory(
|
shm = SharedMemory(
|
||||||
name=key,
|
name=token.shm_name,
|
||||||
create=False,
|
create=False,
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
@ -614,10 +735,10 @@ def attach_shm_ndarray(
|
||||||
sha.array
|
sha.array
|
||||||
|
|
||||||
# Stash key -> token knowledge for future queries
|
# Stash key -> token knowledge for future queries
|
||||||
# via `maybe_opepn_shm_array()` but only after we know
|
# via `maybe_open_shm_ndarray()` but only after
|
||||||
# we can attach.
|
# we know we can attach.
|
||||||
if key not in _known_tokens:
|
if lookup_key not in _known_tokens:
|
||||||
_known_tokens[key] = token
|
_known_tokens[lookup_key] = token
|
||||||
|
|
||||||
# "close" attached shm on actor teardown
|
# "close" attached shm on actor teardown
|
||||||
tractor.current_actor().lifetime_stack.callback(sha.close)
|
tractor.current_actor().lifetime_stack.callback(sha.close)
|
||||||
|
|
@ -661,7 +782,10 @@ def maybe_open_shm_ndarray(
|
||||||
False, # not newly opened
|
False, # not newly opened
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.warning(f"Could not find {key} in shms cache")
|
log.warning(
|
||||||
|
f'Could not find key in shms cache,\n'
|
||||||
|
f'key: {key!r}\n'
|
||||||
|
)
|
||||||
if dtype:
|
if dtype:
|
||||||
token = _make_token(
|
token = _make_token(
|
||||||
key,
|
key,
|
||||||
|
|
@ -771,6 +895,7 @@ def open_shm_list(
|
||||||
size: int = int(2 ** 10),
|
size: int = int(2 ** 10),
|
||||||
dtype: float | int | bool | str | bytes | None = float,
|
dtype: float | int | bool | str | bytes | None = float,
|
||||||
readonly: bool = True,
|
readonly: bool = True,
|
||||||
|
prefix: str = 'shml_',
|
||||||
|
|
||||||
) -> ShmList:
|
) -> ShmList:
|
||||||
|
|
||||||
|
|
@ -784,6 +909,12 @@ def open_shm_list(
|
||||||
}[dtype]
|
}[dtype]
|
||||||
sequence = [default] * size
|
sequence = [default] * size
|
||||||
|
|
||||||
|
if platform.system() == 'Darwin':
|
||||||
|
key: str = _shorten_key_for_macos(
|
||||||
|
key=key,
|
||||||
|
prefix=prefix,
|
||||||
|
)
|
||||||
|
|
||||||
shml = ShmList(
|
shml = ShmList(
|
||||||
sequence=sequence,
|
sequence=sequence,
|
||||||
name=key,
|
name=key,
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ from contextlib import (
|
||||||
)
|
)
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from socket import (
|
from socket import (
|
||||||
AF_UNIX,
|
AF_UNIX,
|
||||||
SOCK_STREAM,
|
SOCK_STREAM,
|
||||||
SO_PASSCRED,
|
|
||||||
SO_PEERCRED,
|
|
||||||
SOL_SOCKET,
|
SOL_SOCKET,
|
||||||
|
error as socket_error,
|
||||||
)
|
)
|
||||||
import struct
|
import struct
|
||||||
from typing import (
|
from typing import (
|
||||||
|
|
@ -53,7 +53,7 @@ from tractor.log import get_logger
|
||||||
from tractor.ipc._transport import (
|
from tractor.ipc._transport import (
|
||||||
MsgpackTransport,
|
MsgpackTransport,
|
||||||
)
|
)
|
||||||
from .._state import (
|
from tractor._state import (
|
||||||
get_rt_dir,
|
get_rt_dir,
|
||||||
current_actor,
|
current_actor,
|
||||||
is_root_process,
|
is_root_process,
|
||||||
|
|
@ -63,6 +63,28 @@ if TYPE_CHECKING:
|
||||||
from ._runtime import Actor
|
from ._runtime import Actor
|
||||||
|
|
||||||
|
|
||||||
|
# Platform-specific credential passing constants
|
||||||
|
# See: https://stackoverflow.com/a/7982749
|
||||||
|
if sys.platform == 'linux':
|
||||||
|
from socket import (
|
||||||
|
SO_PASSCRED,
|
||||||
|
SO_PEERCRED,
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Other (Unix) platforms - though further testing is required and
|
||||||
|
# others may need additional special handling?
|
||||||
|
SO_PASSCRED = None
|
||||||
|
SO_PEERCRED = None
|
||||||
|
|
||||||
|
# NOTE, macOS uses `LOCAL_PEERCRED` instead of `SO_PEERCRED` and
|
||||||
|
# doesn't need `SO_PASSCRED` (credential passing is always enabled).
|
||||||
|
# See code in <sys/un.h>: `#define LOCAL_PEERCRED 0x001`
|
||||||
|
#
|
||||||
|
# XXX INSTEAD we use the (hopefully) more generic
|
||||||
|
# `get_peer_pid()` below for other OSes.
|
||||||
|
|
||||||
|
|
||||||
log = get_logger()
|
log = get_logger()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -165,15 +187,21 @@ class UDSAddress(
|
||||||
err_on_no_runtime=False,
|
err_on_no_runtime=False,
|
||||||
)
|
)
|
||||||
if actor:
|
if actor:
|
||||||
sockname: str = '::'.join(actor.uid) + f'@{pid}'
|
sockname: str = f'{actor.aid.name}@{pid}'
|
||||||
|
# XXX, orig version which broke both macOS (file-name
|
||||||
|
# length) and `multiaddrs` ('::' invalid separator).
|
||||||
|
# sockname: str = '::'.join(actor.uid) + f'@{pid}'
|
||||||
|
#
|
||||||
# ?^TODO, for `multiaddr`'s parser we can't use the `::`
|
# ?^TODO, for `multiaddr`'s parser we can't use the `::`
|
||||||
# above^, SO maybe a `.` or something else here?
|
# above^, SO maybe a `.` or something else here?
|
||||||
# sockname: str = '.'.join(actor.uid) + f'@{pid}'
|
# sockname: str = '.'.join(actor.uid) + f'@{pid}'
|
||||||
# -[ ] CURRENTLY using `.` BREAKS TEST SUITE tho..
|
# -[ ] CURRENTLY using `.` BREAKS TEST SUITE tho..
|
||||||
else:
|
else:
|
||||||
prefix: str = '<unknown-actor>'
|
|
||||||
if is_root_process():
|
if is_root_process():
|
||||||
prefix: str = 'root'
|
prefix: str = 'no_runtime_root'
|
||||||
|
else:
|
||||||
|
prefix: str = 'no_runtime_actor'
|
||||||
|
|
||||||
sockname: str = f'{prefix}@{pid}'
|
sockname: str = f'{prefix}@{pid}'
|
||||||
|
|
||||||
sockpath: Path = Path(f'{sockname}.sock')
|
sockpath: Path = Path(f'{sockname}.sock')
|
||||||
|
|
@ -292,7 +320,12 @@ def close_listener(
|
||||||
|
|
||||||
|
|
||||||
async def open_unix_socket_w_passcred(
|
async def open_unix_socket_w_passcred(
|
||||||
filename: str|bytes|os.PathLike[str]|os.PathLike[bytes],
|
filename: (
|
||||||
|
str
|
||||||
|
|bytes
|
||||||
|
|os.PathLike[str]
|
||||||
|
|os.PathLike[bytes]
|
||||||
|
),
|
||||||
) -> trio.SocketStream:
|
) -> trio.SocketStream:
|
||||||
'''
|
'''
|
||||||
Literally the exact same as `trio.open_unix_socket()` except we set the additiona
|
Literally the exact same as `trio.open_unix_socket()` except we set the additiona
|
||||||
|
|
@ -310,21 +343,66 @@ async def open_unix_socket_w_passcred(
|
||||||
# much more simplified logic vs tcp sockets - one socket type and only one
|
# much more simplified logic vs tcp sockets - one socket type and only one
|
||||||
# possible location to connect to
|
# possible location to connect to
|
||||||
sock = trio.socket.socket(AF_UNIX, SOCK_STREAM)
|
sock = trio.socket.socket(AF_UNIX, SOCK_STREAM)
|
||||||
sock.setsockopt(SOL_SOCKET, SO_PASSCRED, 1)
|
|
||||||
|
# Only set SO_PASSCRED on Linux (not needed/available on macOS)
|
||||||
|
if SO_PASSCRED is not None:
|
||||||
|
sock.setsockopt(SOL_SOCKET, SO_PASSCRED, 1)
|
||||||
|
|
||||||
with close_on_error(sock):
|
with close_on_error(sock):
|
||||||
await sock.connect(os.fspath(filename))
|
await sock.connect(os.fspath(filename))
|
||||||
|
|
||||||
return trio.SocketStream(sock)
|
return trio.SocketStream(sock)
|
||||||
|
|
||||||
|
|
||||||
def get_peer_info(sock: trio.socket.socket) -> tuple[
|
def get_peer_pid(sock) -> int|None:
|
||||||
|
'''
|
||||||
|
Gets the PID of the process connected to the other end of a Unix
|
||||||
|
domain socket on macOS, or `None` if that fails.
|
||||||
|
|
||||||
|
NOTE, should work on MacOS (and others?).
|
||||||
|
|
||||||
|
'''
|
||||||
|
# try to get the peer PID using a naive soln found from,
|
||||||
|
# https://stackoverflow.com/a/67971484
|
||||||
|
#
|
||||||
|
# NOTE, a more correct soln is likely needed here according to
|
||||||
|
# the complaints of `copilot` which led to digging into the
|
||||||
|
# underlying `go`lang issue linked from the above SO answer,
|
||||||
|
|
||||||
|
# XXX, darwin-xnu kernel srces defining these constants,
|
||||||
|
# - SOL_LOCAL
|
||||||
|
# |_https://github.com/apple/darwin-xnu/blob/main/bsd/sys/un.h#L85
|
||||||
|
# - LOCAL_PEERPID
|
||||||
|
# |_https://github.com/apple/darwin-xnu/blob/main/bsd/sys/un.h#L89
|
||||||
|
#
|
||||||
|
SOL_LOCAL: int = 0
|
||||||
|
LOCAL_PEERPID: int = 0x002
|
||||||
|
|
||||||
|
try:
|
||||||
|
pid: int = sock.getsockopt(
|
||||||
|
SOL_LOCAL,
|
||||||
|
LOCAL_PEERPID,
|
||||||
|
)
|
||||||
|
return pid
|
||||||
|
except socket_error as e:
|
||||||
|
log.exception(
|
||||||
|
f"Failed to get peer PID: {e}"
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_peer_info(
|
||||||
|
sock: trio.socket.socket,
|
||||||
|
) -> tuple[
|
||||||
int, # pid
|
int, # pid
|
||||||
int, # uid
|
int, # uid
|
||||||
int, # guid
|
int, # guid
|
||||||
]:
|
]:
|
||||||
'''
|
'''
|
||||||
Deliver the connecting peer's "credentials"-info as defined in
|
Deliver the connecting peer's "credentials"-info as defined in
|
||||||
a very Linux specific way..
|
a platform-specific way.
|
||||||
|
|
||||||
|
Linux-ONLY, uses SO_PEERCRED.
|
||||||
|
|
||||||
For more deats see,
|
For more deats see,
|
||||||
- `man accept`,
|
- `man accept`,
|
||||||
|
|
@ -337,6 +415,11 @@ def get_peer_info(sock: trio.socket.socket) -> tuple[
|
||||||
- https://stackoverflow.com/a/7982749
|
- https://stackoverflow.com/a/7982749
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
if SO_PEERCRED is None:
|
||||||
|
raise RuntimeError(
|
||||||
|
f'Peer credential retrieval not supported on {sys.platform}!'
|
||||||
|
)
|
||||||
|
|
||||||
creds: bytes = sock.getsockopt(
|
creds: bytes = sock.getsockopt(
|
||||||
SOL_SOCKET,
|
SOL_SOCKET,
|
||||||
SO_PEERCRED,
|
SO_PEERCRED,
|
||||||
|
|
@ -440,13 +523,37 @@ class MsgpackUDSStream(MsgpackTransport):
|
||||||
match (peername, sockname):
|
match (peername, sockname):
|
||||||
case (str(), bytes()):
|
case (str(), bytes()):
|
||||||
sock_path: Path = Path(peername)
|
sock_path: Path = Path(peername)
|
||||||
|
|
||||||
case (bytes(), str()):
|
case (bytes(), str()):
|
||||||
sock_path: Path = Path(sockname)
|
sock_path: Path = Path(sockname)
|
||||||
(
|
|
||||||
peer_pid,
|
case (str(), str()): # XXX, likely macOS
|
||||||
_,
|
sock_path: Path = Path(peername)
|
||||||
_,
|
|
||||||
) = get_peer_info(sock)
|
case _:
|
||||||
|
raise TypeError(
|
||||||
|
f'Failed to match (peername, sockname) types?\n'
|
||||||
|
f'peername: {peername!r}\n'
|
||||||
|
f'sockname: {sockname!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
if sys.platform == 'linux':
|
||||||
|
(
|
||||||
|
peer_pid,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
) = get_peer_info(sock)
|
||||||
|
|
||||||
|
# NOTE known to at least works on,
|
||||||
|
# - macos
|
||||||
|
else:
|
||||||
|
peer_pid: int|None = get_peer_pid(sock)
|
||||||
|
if peer_pid is None:
|
||||||
|
log.warning(
|
||||||
|
f'Unable to get peer PID?\n'
|
||||||
|
f'sock: {sock!r}\n'
|
||||||
|
f'peer_pid: {peer_pid!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
filedir, filename = unwrap_sockpath(sock_path)
|
filedir, filename = unwrap_sockpath(sock_path)
|
||||||
laddr = UDSAddress(
|
laddr = UDSAddress(
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ _conc_name_getters = {
|
||||||
'task': pformat_task_uid,
|
'task': pformat_task_uid,
|
||||||
'actor': lambda: _curr_actor_no_exc(),
|
'actor': lambda: _curr_actor_no_exc(),
|
||||||
'actor_name': lambda: current_actor().name,
|
'actor_name': lambda: current_actor().name,
|
||||||
'actor_uid': lambda: current_actor().uid[1][:6],
|
'actor_uid': lambda: current_actor().aid.uuid[:6],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,11 @@ from contextvars import (
|
||||||
)
|
)
|
||||||
import textwrap
|
import textwrap
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
|
||||||
Callable,
|
|
||||||
Protocol,
|
|
||||||
Type,
|
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
TypeVar,
|
Any,
|
||||||
|
Type,
|
||||||
Union,
|
Union,
|
||||||
|
Callable,
|
||||||
)
|
)
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
|
|
||||||
|
|
@ -54,6 +52,13 @@ from msgspec import (
|
||||||
msgpack,
|
msgpack,
|
||||||
Raw,
|
Raw,
|
||||||
)
|
)
|
||||||
|
from msgspec.inspect import (
|
||||||
|
CustomType,
|
||||||
|
UnionType,
|
||||||
|
SetType,
|
||||||
|
ListType,
|
||||||
|
TupleType
|
||||||
|
)
|
||||||
# TODO: see notes below from @mikenerone..
|
# TODO: see notes below from @mikenerone..
|
||||||
# from tricycle import TreeVar
|
# from tricycle import TreeVar
|
||||||
|
|
||||||
|
|
@ -81,7 +86,7 @@ class MsgDec(Struct):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
_dec: msgpack.Decoder
|
_dec: msgpack.Decoder
|
||||||
# _ext_types_box: Struct|None = None
|
_ext_types_boxes: dict[Type, Struct] = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dec(self) -> msgpack.Decoder:
|
def dec(self) -> msgpack.Decoder:
|
||||||
|
|
@ -226,6 +231,8 @@ def mk_dec(
|
||||||
f'ext_types = {ext_types!r}\n'
|
f'ext_types = {ext_types!r}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_boxed_structs: dict[Type, Struct] = {}
|
||||||
|
|
||||||
if dec_hook:
|
if dec_hook:
|
||||||
if ext_types is None:
|
if ext_types is None:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
|
|
@ -237,17 +244,15 @@ def mk_dec(
|
||||||
f'ext_types = {ext_types!r}\n'
|
f'ext_types = {ext_types!r}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
# XXX, i *thought* we would require a boxing struct as per docs,
|
if len(ext_types) > 1:
|
||||||
# https://jcristharif.com/msgspec/extending.html#mapping-to-from-native-types
|
_boxed_structs = mk_boxed_ext_structs(ext_types)
|
||||||
# |_ see comment,
|
ext_types = [
|
||||||
# > Note that typed deserialization is required for
|
etype
|
||||||
# > successful roundtripping here, so we pass `MyMessage` to
|
for etype in ext_types
|
||||||
# > `Decoder`.
|
if etype not in _boxed_structs
|
||||||
#
|
]
|
||||||
# BUT, turns out as long as you spec a union with `Raw` it
|
ext_types += list(_boxed_structs.values())
|
||||||
# will work? kk B)
|
|
||||||
#
|
|
||||||
# maybe_box_struct = mk_boxed_ext_struct(ext_types)
|
|
||||||
spec = Raw | Union[*ext_types]
|
spec = Raw | Union[*ext_types]
|
||||||
|
|
||||||
return MsgDec(
|
return MsgDec(
|
||||||
|
|
@ -255,29 +260,26 @@ def mk_dec(
|
||||||
type=spec, # like `MsgType[Any]`
|
type=spec, # like `MsgType[Any]`
|
||||||
dec_hook=dec_hook,
|
dec_hook=dec_hook,
|
||||||
),
|
),
|
||||||
|
_ext_types_boxes=_boxed_structs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO? remove since didn't end up needing this?
|
def mk_boxed_ext_structs(
|
||||||
def mk_boxed_ext_struct(
|
|
||||||
ext_types: list[Type],
|
ext_types: list[Type],
|
||||||
) -> Struct:
|
) -> dict[Type, Struct]:
|
||||||
# NOTE, originally was to wrap non-msgpack-supported "extension
|
box_types: dict[Type, Struct] = {}
|
||||||
# types" in a field-typed boxing struct, see notes around the
|
for ext_type in ext_types:
|
||||||
# `dec_hook()` branch in `mk_dec()`.
|
info = msgspec.inspect.type_info(ext_type)
|
||||||
ext_types_union = Union[*ext_types]
|
if isinstance(info, CustomType):
|
||||||
repr_ext_types_union: str = (
|
box_types[ext_type] = msgspec.defstruct(
|
||||||
str(ext_types_union)
|
f'Box{ext_type.__name__}',
|
||||||
or
|
tag=True,
|
||||||
"|".join(ext_types)
|
fields=[
|
||||||
)
|
('inner', ext_type),
|
||||||
BoxedExtType = msgspec.defstruct(
|
],
|
||||||
f'BoxedExts[{repr_ext_types_union}]',
|
)
|
||||||
fields=[
|
|
||||||
('boxed', ext_types_union),
|
return box_types
|
||||||
],
|
|
||||||
)
|
|
||||||
return BoxedExtType
|
|
||||||
|
|
||||||
|
|
||||||
def unpack_spec_types(
|
def unpack_spec_types(
|
||||||
|
|
@ -378,7 +380,7 @@ class MsgCodec(Struct):
|
||||||
_dec: msgpack.Decoder
|
_dec: msgpack.Decoder
|
||||||
_pld_spec: Type[Struct]|Raw|Any
|
_pld_spec: Type[Struct]|Raw|Any
|
||||||
|
|
||||||
# _ext_types_box: Struct|None = None
|
_ext_types_boxes: dict[Type, Struct] = {}
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
speclines: str = textwrap.indent(
|
speclines: str = textwrap.indent(
|
||||||
|
|
@ -465,45 +467,29 @@ class MsgCodec(Struct):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
__tracebackhide__: bool = hide_tb
|
__tracebackhide__: bool = hide_tb
|
||||||
if use_buf:
|
|
||||||
self._enc.encode_into(py_obj, self._buf)
|
|
||||||
return self._buf
|
|
||||||
|
|
||||||
return self._enc.encode(py_obj)
|
try:
|
||||||
# try:
|
|
||||||
# return self._enc.encode(py_obj)
|
|
||||||
# except TypeError as typerr:
|
|
||||||
# typerr.add_note(
|
|
||||||
# '|_src error from `msgspec`'
|
|
||||||
# # f'|_{self._enc.encode!r}'
|
|
||||||
# )
|
|
||||||
# raise typerr
|
|
||||||
|
|
||||||
# TODO! REMOVE once i'm confident we won't ever need it!
|
box: Struct|None = self._ext_types_boxes.get(type(py_obj), None)
|
||||||
#
|
if (
|
||||||
# box: Struct = self._ext_types_box
|
as_ext_type
|
||||||
# if (
|
or
|
||||||
# as_ext_type
|
box
|
||||||
# or
|
):
|
||||||
# (
|
py_obj = box(inner=py_obj)
|
||||||
# # XXX NOTE, auto-detect if the input type
|
|
||||||
# box
|
if use_buf:
|
||||||
# and
|
self._enc.encode_into(py_obj, self._buf)
|
||||||
# (ext_types := unpack_spec_types(
|
return self._buf
|
||||||
# spec=box.__annotations__['boxed'])
|
|
||||||
# )
|
return self._enc.encode(py_obj)
|
||||||
# )
|
|
||||||
# ):
|
except TypeError as typerr:
|
||||||
# match py_obj:
|
typerr.add_note(
|
||||||
# # case PayloadMsg(pld=pld) if (
|
'|_src error from `msgspec`'
|
||||||
# # type(pld) in ext_types
|
# f'|_{self._enc.encode!r}'
|
||||||
# # ):
|
)
|
||||||
# # py_obj.pld = box(boxed=py_obj)
|
raise typerr
|
||||||
# # breakpoint()
|
|
||||||
# case _ if (
|
|
||||||
# type(py_obj) in ext_types
|
|
||||||
# ):
|
|
||||||
# py_obj = box(boxed=py_obj)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dec(self) -> msgpack.Decoder:
|
def dec(self) -> msgpack.Decoder:
|
||||||
|
|
@ -565,11 +551,6 @@ def mk_codec(
|
||||||
enc_hook: Callable|None = None,
|
enc_hook: Callable|None = None,
|
||||||
ext_types: list[Type]|None = None,
|
ext_types: list[Type]|None = None,
|
||||||
|
|
||||||
# optionally provided msg-decoder from which we pull its,
|
|
||||||
# |_.dec_hook()
|
|
||||||
# |_.type
|
|
||||||
ext_dec: MsgDec|None = None
|
|
||||||
#
|
|
||||||
# ?TODO? other params we might want to support
|
# ?TODO? other params we might want to support
|
||||||
# Encoder:
|
# Encoder:
|
||||||
# write_buffer_size=write_buffer_size,
|
# write_buffer_size=write_buffer_size,
|
||||||
|
|
@ -597,12 +578,6 @@ def mk_codec(
|
||||||
)
|
)
|
||||||
|
|
||||||
dec_hook: Callable|None = None
|
dec_hook: Callable|None = None
|
||||||
if ext_dec:
|
|
||||||
dec: msgspec.Decoder = ext_dec.dec
|
|
||||||
dec_hook = dec.dec_hook
|
|
||||||
pld_spec |= dec.type
|
|
||||||
if ext_types:
|
|
||||||
pld_spec |= Union[*ext_types]
|
|
||||||
|
|
||||||
# (manually) generate a msg-spec (how appropes) for all relevant
|
# (manually) generate a msg-spec (how appropes) for all relevant
|
||||||
# payload-boxing-struct-msg-types, parameterizing the
|
# payload-boxing-struct-msg-types, parameterizing the
|
||||||
|
|
@ -630,10 +605,16 @@ def mk_codec(
|
||||||
enc = msgpack.Encoder(
|
enc = msgpack.Encoder(
|
||||||
enc_hook=enc_hook,
|
enc_hook=enc_hook,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
boxes = {}
|
||||||
|
if ext_types and len(ext_types) > 1:
|
||||||
|
boxes = mk_boxed_ext_structs(ext_types)
|
||||||
|
|
||||||
codec = MsgCodec(
|
codec = MsgCodec(
|
||||||
_enc=enc,
|
_enc=enc,
|
||||||
_dec=dec,
|
_dec=dec,
|
||||||
_pld_spec=pld_spec,
|
_pld_spec=pld_spec,
|
||||||
|
_ext_types_boxes=boxes
|
||||||
)
|
)
|
||||||
# sanity on expected backend support
|
# sanity on expected backend support
|
||||||
assert codec.lib.__name__ == libname
|
assert codec.lib.__name__ == libname
|
||||||
|
|
@ -809,78 +790,298 @@ def limit_msg_spec(
|
||||||
assert curr_codec is current_codec()
|
assert curr_codec is current_codec()
|
||||||
|
|
||||||
|
|
||||||
# XXX: msgspec won't allow this with non-struct custom types
|
'''
|
||||||
# like `NamespacePath`!@!
|
Encoder / Decoder generic hook factory
|
||||||
# @cm
|
|
||||||
# def extend_msg_spec(
|
|
||||||
# payload_spec: Union[Type[Struct]],
|
|
||||||
|
|
||||||
# ) -> MsgCodec:
|
'''
|
||||||
# '''
|
|
||||||
# Extend the current `MsgCodec.pld_spec` (type set) by extending
|
|
||||||
# the payload spec to **include** the types specified by
|
|
||||||
# `payload_spec`.
|
|
||||||
|
|
||||||
# '''
|
|
||||||
# codec: MsgCodec = current_codec()
|
|
||||||
# pld_spec: Union[Type] = codec.pld_spec
|
|
||||||
# extended_spec: Union[Type] = pld_spec|payload_spec
|
|
||||||
|
|
||||||
# with limit_msg_spec(payload_types=extended_spec) as ext_codec:
|
|
||||||
# # import pdbp; pdbp.set_trace()
|
|
||||||
# assert ext_codec.pld_spec == extended_spec
|
|
||||||
# yield ext_codec
|
|
||||||
#
|
|
||||||
# ^-TODO-^ is it impossible to make something like this orr!?
|
|
||||||
|
|
||||||
# TODO: make an auto-custom hook generator from a set of input custom
|
|
||||||
# types?
|
|
||||||
# -[ ] below is a proto design using a `TypeCodec` idea?
|
|
||||||
#
|
|
||||||
# type var for the expected interchange-lib's
|
|
||||||
# IPC-transport type when not available as a built-in
|
|
||||||
# serialization output.
|
|
||||||
WireT = TypeVar('WireT')
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: some kinda (decorator) API for built-in subtypes
|
# builtins we can have in same pld_spec as custom types
|
||||||
# that builds this implicitly by inspecting the `mro()`?
|
default_builtins = (
|
||||||
class TypeCodec(Protocol):
|
None,
|
||||||
|
bool,
|
||||||
|
int,
|
||||||
|
float,
|
||||||
|
bytes,
|
||||||
|
list
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# spec definition type
|
||||||
|
TypeSpec = (
|
||||||
|
Type |
|
||||||
|
Union[Type] |
|
||||||
|
list[Type] |
|
||||||
|
tuple[Type] |
|
||||||
|
set[Type]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TypeCodec:
|
||||||
'''
|
'''
|
||||||
A per-custom-type wire-transport serialization translator
|
This class describes a way of encoding to or decoding from a "wire type",
|
||||||
description type.
|
objects that have `encode_fn` and `decode_fn` can be used with
|
||||||
|
`.encode/.decode`.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
src_type: Type
|
|
||||||
wire_type: WireT
|
|
||||||
|
|
||||||
def encode(obj: Type) -> WireT:
|
def __init__(
|
||||||
...
|
self,
|
||||||
|
wire_type: Type,
|
||||||
|
decode_fn: str,
|
||||||
|
encode_fn: str = 'encode',
|
||||||
|
):
|
||||||
|
self._encode_fn: str = encode_fn
|
||||||
|
self._decode_fn: str = decode_fn
|
||||||
|
self._wire_type: Type = wire_type
|
||||||
|
|
||||||
def decode(
|
def __repr__(self) -> str:
|
||||||
obj_type: Type[WireT],
|
return (
|
||||||
obj: WireT,
|
f'{type(self).__name__}('
|
||||||
) -> Type:
|
f'{self._encode_fn}, '
|
||||||
...
|
f'{self._decode_fn}) '
|
||||||
|
f'-> {self._wire_type}'
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def encode_fn(self) -> str:
|
||||||
|
return self._encode_fn
|
||||||
|
|
||||||
|
@property
|
||||||
|
def decode_fn(self) -> str:
|
||||||
|
return self._decode_fn
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wire_type(self) -> str:
|
||||||
|
return self._wire_type
|
||||||
|
|
||||||
|
def is_type_compat(self, obj: any) -> bool:
|
||||||
|
return (
|
||||||
|
hasattr(obj, self._encode_fn)
|
||||||
|
and
|
||||||
|
hasattr(obj, self._decode_fn)
|
||||||
|
)
|
||||||
|
|
||||||
|
def encode(self, obj: any) -> any:
|
||||||
|
return getattr(obj, self._encode_fn)()
|
||||||
|
|
||||||
|
def decode(self, cls: Type, raw: any) -> any:
|
||||||
|
return getattr(cls, self._decode_fn)(raw)
|
||||||
|
|
||||||
|
|
||||||
class MsgpackTypeCodec(TypeCodec):
|
'''
|
||||||
...
|
Default codec descriptions for wire types:
|
||||||
|
|
||||||
|
- bytes
|
||||||
|
- str
|
||||||
|
- int
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
def mk_codec_hooks(
|
BytesCodec = TypeCodec(
|
||||||
type_codecs: list[TypeCodec],
|
decode_fn='from_bytes',
|
||||||
|
wire_type=bytes
|
||||||
|
)
|
||||||
|
|
||||||
) -> tuple[Callable, Callable]:
|
|
||||||
|
StrCodec = TypeCodec(
|
||||||
|
decode_fn='from_str',
|
||||||
|
wire_type=str
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
IntCodec = TypeCodec(
|
||||||
|
decode_fn='from_int',
|
||||||
|
wire_type=int
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
default_codecs: dict[Type, TypeCodec] = {
|
||||||
|
bytes: BytesCodec,
|
||||||
|
str: StrCodec,
|
||||||
|
int: IntCodec
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def mk_spec_set(
|
||||||
|
spec: TypeSpec
|
||||||
|
) -> set[Type]:
|
||||||
'''
|
'''
|
||||||
Deliver a `enc_hook()`/`dec_hook()` pair which handle
|
Given any of the different spec definitions, always return a `set[Type]`
|
||||||
manual convertion from an input `Type` set such that whenever
|
with each spec type as an item.
|
||||||
the `TypeCodec.filter()` predicate matches the
|
|
||||||
`TypeCodec.decode()` is called on the input native object by
|
- When passed list|tuple|set do nothing
|
||||||
the `dec_hook()` and whenever the
|
- When passed a single type we wrap it in tuple
|
||||||
`isiinstance(obj, TypeCodec.type)` matches against an
|
- When passed a Union we wrap its inner types in tuple
|
||||||
`enc_hook(obj=obj)` the return value is taken from a
|
|
||||||
`TypeCodec.encode(obj)` callback.
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
...
|
if not (
|
||||||
|
isinstance(spec, set)
|
||||||
|
or
|
||||||
|
isinstance(spec, list)
|
||||||
|
or
|
||||||
|
isinstance(spec, tuple)
|
||||||
|
):
|
||||||
|
spec_info = msgspec.inspect.type_info(spec)
|
||||||
|
match spec_info:
|
||||||
|
case UnionType():
|
||||||
|
return set((
|
||||||
|
t.cls
|
||||||
|
for t in spec_info.types
|
||||||
|
))
|
||||||
|
|
||||||
|
case _:
|
||||||
|
return set((spec, ))
|
||||||
|
|
||||||
|
return set(spec)
|
||||||
|
|
||||||
|
|
||||||
|
def mk_codec_map_from_spec(
|
||||||
|
spec: TypeSpec,
|
||||||
|
codecs: dict[Type, TypeCodec] = default_codecs
|
||||||
|
) -> dict[Type, TypeCodec]:
|
||||||
|
'''
|
||||||
|
Generate a map of spec type -> supported codec
|
||||||
|
|
||||||
|
'''
|
||||||
|
spec: set[Type] = mk_spec_set(spec)
|
||||||
|
|
||||||
|
spec_codecs: dict[Type, TypeCodec] = {}
|
||||||
|
for t in spec:
|
||||||
|
if t in spec_codecs:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for codec_type in (int, bytes, str):
|
||||||
|
codec = codecs[codec_type]
|
||||||
|
if codec.is_type_compat(t):
|
||||||
|
spec_codecs[t] = codec
|
||||||
|
break
|
||||||
|
|
||||||
|
return spec_codecs
|
||||||
|
|
||||||
|
|
||||||
|
def mk_enc_hook(
|
||||||
|
spec: TypeSpec,
|
||||||
|
with_builtins: bool = True,
|
||||||
|
builtins: set[Type] = default_builtins,
|
||||||
|
codecs: dict[Type, TypeCodec] = default_codecs
|
||||||
|
) -> Callable:
|
||||||
|
'''
|
||||||
|
Given a type specification return a msgspec enc_hook fn
|
||||||
|
|
||||||
|
'''
|
||||||
|
spec_codecs = mk_codec_map_from_spec(spec)
|
||||||
|
|
||||||
|
def enc_hook(obj: any) -> any:
|
||||||
|
try:
|
||||||
|
t = type(obj)
|
||||||
|
maybe_codec = spec_codecs.get(t, None)
|
||||||
|
if maybe_codec:
|
||||||
|
return maybe_codec.encode(obj)
|
||||||
|
|
||||||
|
# passthrough builtins
|
||||||
|
if builtins and t in builtins:
|
||||||
|
return obj
|
||||||
|
|
||||||
|
raise NotImplementedError(
|
||||||
|
f"Objects of type {type(obj)} are not supported:\n{obj}"
|
||||||
|
)
|
||||||
|
|
||||||
|
except* Exception as e:
|
||||||
|
e.add_note(f'enc_hook: {t}, {type(obj)} {obj}')
|
||||||
|
raise
|
||||||
|
|
||||||
|
return enc_hook
|
||||||
|
|
||||||
|
|
||||||
|
def mk_dec_hook(
|
||||||
|
spec: TypeSpec,
|
||||||
|
with_builtins: bool = True,
|
||||||
|
builtins: set[Type] = default_builtins,
|
||||||
|
codecs: dict[Type, TypeCodec] = default_codecs
|
||||||
|
) -> Callable:
|
||||||
|
'''
|
||||||
|
Given a type specification return a msgspec dec_hook fn
|
||||||
|
|
||||||
|
'''
|
||||||
|
spec_codecs = mk_codec_map_from_spec(spec)
|
||||||
|
|
||||||
|
def dec_hook(t: Type, obj: any) -> any:
|
||||||
|
try:
|
||||||
|
if t is type(obj):
|
||||||
|
return obj
|
||||||
|
|
||||||
|
maybe_codec = spec_codecs.get(t, None)
|
||||||
|
if maybe_codec:
|
||||||
|
return maybe_codec.decode(t, obj)
|
||||||
|
|
||||||
|
# passthrough builtins
|
||||||
|
if builtins and type(obj) in builtins:
|
||||||
|
return obj
|
||||||
|
|
||||||
|
raise NotImplementedError(
|
||||||
|
f"Objects of type {type} are not supported from {obj}"
|
||||||
|
)
|
||||||
|
|
||||||
|
except* Exception as e:
|
||||||
|
e.add_note(f'dec_hook: {t}, {type(obj)} {obj}')
|
||||||
|
raise
|
||||||
|
|
||||||
|
return dec_hook
|
||||||
|
|
||||||
|
|
||||||
|
def mk_codec_hooks(*args, **kwargs) -> tuple[Callable, Callable]:
|
||||||
|
'''
|
||||||
|
Given a type specification return a msgspec enc & dec hook fn pair
|
||||||
|
|
||||||
|
'''
|
||||||
|
return (
|
||||||
|
mk_enc_hook(*args, **kwargs),
|
||||||
|
|
||||||
|
mk_dec_hook(*args, **kwargs)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def mk_codec_from_spec(
|
||||||
|
spec: TypeSpec,
|
||||||
|
with_builtins: bool = True,
|
||||||
|
builtins: set[Type] = default_builtins,
|
||||||
|
codecs: dict[Type, TypeCodec] = default_codecs
|
||||||
|
) -> MsgCodec:
|
||||||
|
'''
|
||||||
|
Given a type specification return a MsgCodec
|
||||||
|
|
||||||
|
'''
|
||||||
|
spec: set[Type] = mk_spec_set(spec)
|
||||||
|
|
||||||
|
return mk_codec(
|
||||||
|
enc_hook=mk_enc_hook(
|
||||||
|
spec,
|
||||||
|
with_builtins=with_builtins,
|
||||||
|
builtins=builtins,
|
||||||
|
codecs=codecs
|
||||||
|
),
|
||||||
|
ext_types=spec
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def mk_msgpack_codec(
|
||||||
|
spec: TypeSpec,
|
||||||
|
with_builtins: bool = True,
|
||||||
|
builtins: set[Type] = default_builtins,
|
||||||
|
codecs: dict[Type, TypeCodec] = default_codecs
|
||||||
|
) -> tuple[msgpack.Encoder, msgpack.Decoder]:
|
||||||
|
'''
|
||||||
|
Get a msgpack Encoder, Decoder pair for a given type spec
|
||||||
|
|
||||||
|
'''
|
||||||
|
enc_hook, dec_hook = mk_codec_hooks(
|
||||||
|
spec,
|
||||||
|
with_builtins=with_builtins,
|
||||||
|
builtins=builtins,
|
||||||
|
codecs=codecs
|
||||||
|
)
|
||||||
|
encoder = msgpack.Encoder(enc_hook=enc_hook)
|
||||||
|
decoder = msgpack.Decoder(spec, dec_hook=dec_hook)
|
||||||
|
return encoder, decoder
|
||||||
|
|
|
||||||
|
|
@ -126,13 +126,17 @@ def iter_struct_ppfmt_lines(
|
||||||
str(ft)
|
str(ft)
|
||||||
).replace(' ', '')
|
).replace(' ', '')
|
||||||
|
|
||||||
|
if k[0] == '_':
|
||||||
|
continue
|
||||||
|
|
||||||
# recurse to get sub-struct's `.pformat()` output Bo
|
# recurse to get sub-struct's `.pformat()` output Bo
|
||||||
if isinstance(v, Struct):
|
elif isinstance(v, Struct):
|
||||||
yield from iter_struct_ppfmt_lines(
|
yield from iter_struct_ppfmt_lines(
|
||||||
struct=v,
|
struct=v,
|
||||||
field_indent=field_indent+field_indent,
|
field_indent=field_indent+field_indent,
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
|
else: # top-level field
|
||||||
val_str: str = repr(v)
|
val_str: str = repr(v)
|
||||||
|
|
||||||
# XXX LOL, below just seems to be f#$%in causing
|
# XXX LOL, below just seems to be f#$%in causing
|
||||||
|
|
@ -149,10 +153,10 @@ def iter_struct_ppfmt_lines(
|
||||||
# raise
|
# raise
|
||||||
# return _Struct.__repr__(struct)
|
# return _Struct.__repr__(struct)
|
||||||
|
|
||||||
yield (
|
yield (
|
||||||
' '*field_indent, # indented ws prefix
|
' '*field_indent, # indented ws prefix
|
||||||
f'{k}: {typ_name} = {val_str},', # field's repr line content
|
f'{k}: {typ_name} = {val_str},', # field's repr line content
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def pformat(
|
def pformat(
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,8 @@ class Start(
|
||||||
# => SEE ABOVE <=
|
# => SEE ABOVE <=
|
||||||
kwargs: dict[str, Any]
|
kwargs: dict[str, Any]
|
||||||
uid: tuple[str, str] # (calling) actor-id
|
uid: tuple[str, str] # (calling) actor-id
|
||||||
|
# aid: Aid
|
||||||
|
# ^TODO, convert stat!
|
||||||
|
|
||||||
# TODO: enforcing a msg-spec in terms `Msg.pld`
|
# TODO: enforcing a msg-spec in terms `Msg.pld`
|
||||||
# parameterizable msgs to be used in the appls IPC dialog.
|
# parameterizable msgs to be used in the appls IPC dialog.
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ from tractor._state import (
|
||||||
_runtime_vars,
|
_runtime_vars,
|
||||||
)
|
)
|
||||||
from tractor._context import Unresolved
|
from tractor._context import Unresolved
|
||||||
from tractor.devx import debug
|
from tractor import devx
|
||||||
from tractor.log import (
|
from tractor.log import (
|
||||||
get_logger,
|
get_logger,
|
||||||
StackLevelAdapter,
|
StackLevelAdapter,
|
||||||
|
|
@ -94,10 +94,14 @@ else:
|
||||||
QueueShutDown = False
|
QueueShutDown = False
|
||||||
|
|
||||||
|
|
||||||
# TODO, generally speaking we can generalize this abstraction, a "SC linked
|
# TODO, generally speaking we can generalize this abstraction as,
|
||||||
# parent->child task pair", as the same "supervision scope primitive"
|
#
|
||||||
# **that is** our `._context.Context` with the only difference being
|
# > A "SC linked, inter-event-loop" channel for comms between
|
||||||
# in how the tasks conduct msg-passing comms.
|
# > a `parent: trio.Task` -> `child: asyncio.Task` pair.
|
||||||
|
#
|
||||||
|
# It is **very similar** in terms of its operation as a "supervision
|
||||||
|
# scope primitive" to that of our `._context.Context` with the only
|
||||||
|
# difference being in how the tasks conduct msg-passing comms.
|
||||||
#
|
#
|
||||||
# For `LinkedTaskChannel` we are passing the equivalent of (once you
|
# For `LinkedTaskChannel` we are passing the equivalent of (once you
|
||||||
# include all the recently added `._trio/aio_to_raise`
|
# include all the recently added `._trio/aio_to_raise`
|
||||||
|
|
@ -122,6 +126,7 @@ class LinkedTaskChannel(
|
||||||
task scheduled in the host loop.
|
task scheduled in the host loop.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
# ?TODO, rename as `._aio_q` since it's 2-way?
|
||||||
_to_aio: asyncio.Queue
|
_to_aio: asyncio.Queue
|
||||||
_from_aio: trio.MemoryReceiveChannel
|
_from_aio: trio.MemoryReceiveChannel
|
||||||
|
|
||||||
|
|
@ -235,9 +240,11 @@ class LinkedTaskChannel(
|
||||||
#
|
#
|
||||||
async def receive(self) -> Any:
|
async def receive(self) -> Any:
|
||||||
'''
|
'''
|
||||||
Receive a value from the paired `asyncio.Task` with
|
Receive a value `trio.Task` <- `asyncio.Task`.
|
||||||
|
|
||||||
|
Note the tasks in each loop are "SC linked" as a pair with
|
||||||
exception/cancel handling to teardown both sides on any
|
exception/cancel handling to teardown both sides on any
|
||||||
unexpected error.
|
unexpected error or cancellation.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
|
|
@ -261,15 +268,40 @@ class LinkedTaskChannel(
|
||||||
):
|
):
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
|
async def get(self) -> Any:
|
||||||
|
'''
|
||||||
|
Receive a value `asyncio.Task` <- `trio.Task`.
|
||||||
|
|
||||||
|
This is equiv to `await self._to_aio.get()`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
return await self._to_aio.get()
|
||||||
|
|
||||||
async def send(self, item: Any) -> None:
|
async def send(self, item: Any) -> None:
|
||||||
'''
|
'''
|
||||||
Send a value through to the asyncio task presuming
|
Send a value `trio.Task` -> `asyncio.Task`
|
||||||
it defines a ``from_trio`` argument, if it does not
|
by enqueuing `item` onto the internal
|
||||||
this method will raise an error.
|
`asyncio.Queue` via `put_nowait()`.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
self._to_aio.put_nowait(item)
|
self._to_aio.put_nowait(item)
|
||||||
|
|
||||||
|
# TODO? could we only compile-in this method on an instance
|
||||||
|
# handed to the `asyncio`-side, i.e. the fn invoked with
|
||||||
|
# `.open_channel_from()`.
|
||||||
|
def send_nowait(
|
||||||
|
self,
|
||||||
|
item: Any,
|
||||||
|
) -> None:
|
||||||
|
'''
|
||||||
|
Send a value through FROM the `asyncio.Task` to
|
||||||
|
the `trio.Task` NON-BLOCKING.
|
||||||
|
|
||||||
|
This is equiv to `self._to_trio.send_nowait()`.
|
||||||
|
|
||||||
|
'''
|
||||||
|
self._to_trio.send_nowait(item)
|
||||||
|
|
||||||
# TODO? needed?
|
# TODO? needed?
|
||||||
# async def wait_aio_complete(self) -> None:
|
# async def wait_aio_complete(self) -> None:
|
||||||
# await self._aio_task_complete.wait()
|
# await self._aio_task_complete.wait()
|
||||||
|
|
@ -337,9 +369,12 @@ def _run_asyncio_task(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
__tracebackhide__: bool = hide_tb
|
__tracebackhide__: bool = hide_tb
|
||||||
if not tractor.current_actor().is_infected_aio():
|
if not (actor := tractor.current_actor()).is_infected_aio():
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"`infect_asyncio` mode is not enabled!?"
|
f'`infect_asyncio: bool` mode is not enabled ??\n'
|
||||||
|
f'Ensure you pass `ActorNursery.start_actor(infect_asyncio=True)`\n'
|
||||||
|
f'\n'
|
||||||
|
f'{actor}\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
# ITC (inter task comms), these channel/queue names are mostly from
|
# ITC (inter task comms), these channel/queue names are mostly from
|
||||||
|
|
@ -402,7 +437,23 @@ def _run_asyncio_task(
|
||||||
|
|
||||||
orig = result = id(coro)
|
orig = result = id(coro)
|
||||||
try:
|
try:
|
||||||
|
# XXX TODO UGH!
|
||||||
|
# this seems to break a `test_sync_pause_from_aio_task`
|
||||||
|
# in a REALLY weird way where a `dict` value for
|
||||||
|
# `_runtime_vars['_root_addrs']` is delivered from the
|
||||||
|
# parent actor??
|
||||||
|
#
|
||||||
|
# XXX => see masked `.set_trace()` block in
|
||||||
|
# `Actor.from_parent()`..
|
||||||
|
#
|
||||||
|
# with devx.maybe_open_crash_handler(
|
||||||
|
# # XXX, if trio-side exits (intentionally) we
|
||||||
|
# # shouldn't care bc it should have its own crash
|
||||||
|
# # handling logic.
|
||||||
|
# ignore={TrioTaskExited,},
|
||||||
|
# ) as _bxerr:
|
||||||
result: Any = await coro
|
result: Any = await coro
|
||||||
|
|
||||||
chan._aio_result = result
|
chan._aio_result = result
|
||||||
except BaseException as aio_err:
|
except BaseException as aio_err:
|
||||||
chan._aio_err = aio_err
|
chan._aio_err = aio_err
|
||||||
|
|
@ -509,7 +560,7 @@ def _run_asyncio_task(
|
||||||
if (
|
if (
|
||||||
debug_mode()
|
debug_mode()
|
||||||
and
|
and
|
||||||
(greenback := debug.maybe_import_greenback(
|
(greenback := devx.debug.maybe_import_greenback(
|
||||||
force_reload=True,
|
force_reload=True,
|
||||||
raise_not_found=False,
|
raise_not_found=False,
|
||||||
))
|
))
|
||||||
|
|
@ -909,7 +960,11 @@ async def translate_aio_errors(
|
||||||
except BaseException as _trio_err:
|
except BaseException as _trio_err:
|
||||||
trio_err = chan._trio_err = _trio_err
|
trio_err = chan._trio_err = _trio_err
|
||||||
# await tractor.pause(shield=True) # workx!
|
# await tractor.pause(shield=True) # workx!
|
||||||
entered: bool = await debug._maybe_enter_pm(
|
|
||||||
|
# !TODO! we need an inter-loop lock here to avoid aio-tasks
|
||||||
|
# clobbering trio ones when both crash in debug-mode!
|
||||||
|
#
|
||||||
|
entered: bool = await devx.debug._maybe_enter_pm(
|
||||||
trio_err,
|
trio_err,
|
||||||
api_frame=inspect.currentframe(),
|
api_frame=inspect.currentframe(),
|
||||||
)
|
)
|
||||||
|
|
@ -1243,10 +1298,18 @@ async def open_channel_from(
|
||||||
suppress_graceful_exits: bool = True,
|
suppress_graceful_exits: bool = True,
|
||||||
**target_kwargs,
|
**target_kwargs,
|
||||||
|
|
||||||
) -> AsyncIterator[Any]:
|
) -> AsyncIterator[
|
||||||
|
tuple[LinkedTaskChannel, Any]
|
||||||
|
]:
|
||||||
'''
|
'''
|
||||||
Open an inter-loop linked task channel for streaming between a target
|
Start an `asyncio.Task` as `target()` and open an
|
||||||
spawned ``asyncio`` task and ``trio``.
|
inter-loop (linked) channel for streaming between
|
||||||
|
it and the current `trio.Task`.
|
||||||
|
|
||||||
|
A pair `(chan: LinkedTaskChannel, Any)` is delivered
|
||||||
|
to the caller where the 2nd element is the value
|
||||||
|
provided by the `asyncio.Task`'s unblocking call
|
||||||
|
to `chan.started_nowait()`.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
chan: LinkedTaskChannel = _run_asyncio_task(
|
chan: LinkedTaskChannel = _run_asyncio_task(
|
||||||
|
|
@ -1270,7 +1333,7 @@ async def open_channel_from(
|
||||||
first = await chan.receive()
|
first = await chan.receive()
|
||||||
|
|
||||||
# deliver stream handle upward
|
# deliver stream handle upward
|
||||||
yield first, chan
|
yield chan, first
|
||||||
except trio.Cancelled as taskc:
|
except trio.Cancelled as taskc:
|
||||||
if cs.cancel_called:
|
if cs.cancel_called:
|
||||||
if isinstance(chan._trio_to_raise, AsyncioCancelled):
|
if isinstance(chan._trio_to_raise, AsyncioCancelled):
|
||||||
|
|
@ -1301,7 +1364,8 @@ async def open_channel_from(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# XXX SHOULD NEVER HAPPEN!
|
# XXX SHOULD NEVER HAPPEN!
|
||||||
await tractor.pause()
|
log.error("SHOULD NEVER GET HERE !?!?")
|
||||||
|
await tractor.pause(shield=True)
|
||||||
else:
|
else:
|
||||||
chan._to_trio.close()
|
chan._to_trio.close()
|
||||||
|
|
||||||
|
|
|
||||||
82
uv.lock
82
uv.lock
|
|
@ -1,6 +1,6 @@
|
||||||
version = 1
|
version = 1
|
||||||
revision = 3
|
revision = 3
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.12, <3.14"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "attrs"
|
name = "attrs"
|
||||||
|
|
@ -29,18 +29,6 @@ dependencies = [
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824", size = 516621, upload-time = "2024-09-04T20:45:21.852Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824", size = 516621, upload-time = "2024-09-04T20:45:21.852Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/6b/f4/927e3a8899e52a27fa57a48607ff7dc91a9ebe97399b357b85a0c7892e00/cffi-1.17.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a45e3c6913c5b87b3ff120dcdc03f6131fa0065027d0ed7ee6190736a74cd401", size = 182264, upload-time = "2024-09-04T20:43:51.124Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/6c/f5/6c3a8efe5f503175aaddcbea6ad0d2c96dad6f5abb205750d1b3df44ef29/cffi-1.17.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:30c5e0cb5ae493c04c8b42916e52ca38079f1b235c2f8ae5f4527b963c401caf", size = 178651, upload-time = "2024-09-04T20:43:52.872Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/94/dd/a3f0118e688d1b1a57553da23b16bdade96d2f9bcda4d32e7d2838047ff7/cffi-1.17.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f75c7ab1f9e4aca5414ed4d8e5c0e303a34f4421f8a0d47a4d019ceff0ab6af4", size = 445259, upload-time = "2024-09-04T20:43:56.123Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/2e/ea/70ce63780f096e16ce8588efe039d3c4f91deb1dc01e9c73a287939c79a6/cffi-1.17.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a1ed2dd2972641495a3ec98445e09766f077aee98a1c896dcb4ad0d303628e41", size = 469200, upload-time = "2024-09-04T20:43:57.891Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/1c/a0/a4fa9f4f781bda074c3ddd57a572b060fa0df7655d2a4247bbe277200146/cffi-1.17.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:46bf43160c1a35f7ec506d254e5c890f3c03648a4dbac12d624e4490a7046cd1", size = 477235, upload-time = "2024-09-04T20:44:00.18Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/62/12/ce8710b5b8affbcdd5c6e367217c242524ad17a02fe5beec3ee339f69f85/cffi-1.17.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a24ed04c8ffd54b0729c07cee15a81d964e6fee0e3d4d342a27b020d22959dc6", size = 459721, upload-time = "2024-09-04T20:44:01.585Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/ff/6b/d45873c5e0242196f042d555526f92aa9e0c32355a1be1ff8c27f077fd37/cffi-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:610faea79c43e44c71e1ec53a554553fa22321b65fae24889706c0a84d4ad86d", size = 467242, upload-time = "2024-09-04T20:44:03.467Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/1a/52/d9a0e523a572fbccf2955f5abe883cfa8bcc570d7faeee06336fbd50c9fc/cffi-1.17.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a9b15d491f3ad5d692e11f6b71f7857e7835eb677955c00cc0aefcd0669adaf6", size = 477999, upload-time = "2024-09-04T20:44:05.023Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/44/74/f2a2460684a1a2d00ca799ad880d54652841a780c4c97b87754f660c7603/cffi-1.17.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:de2ea4b5833625383e464549fec1bc395c1bdeeb5f25c4a3a82b5a8c756ec22f", size = 454242, upload-time = "2024-09-04T20:44:06.444Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f8/4a/34599cac7dfcd888ff54e801afe06a19c17787dfd94495ab0c8d35fe99fb/cffi-1.17.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fc48c783f9c87e60831201f2cce7f3b2e4846bf4d8728eabe54d60700b318a0b", size = 478604, upload-time = "2024-09-04T20:44:08.206Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/34/33/e1b8a1ba29025adbdcda5fb3a36f94c03d771c1b7b12f726ff7fef2ebe36/cffi-1.17.1-cp311-cp311-win32.whl", hash = "sha256:85a950a4ac9c359340d5963966e3e0a94a676bd6245a4b55bc43949eee26a655", size = 171727, upload-time = "2024-09-04T20:44:09.481Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/3d/97/50228be003bb2802627d28ec0627837ac0bf35c90cf769812056f235b2d1/cffi-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:caaf0640ef5f5517f49bc275eca1406b0ffa6aa184892812030f04c2abf589a0", size = 181400, upload-time = "2024-09-04T20:44:10.873Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/5a/84/e94227139ee5fb4d600a7a4927f322e1d4aea6fdc50bd3fca8493caba23f/cffi-1.17.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:805b4371bf7197c329fcb3ead37e710d1bca9da5d583f5073b799d5c5bd1eee4", size = 183178, upload-time = "2024-09-04T20:44:12.232Z" },
|
{ url = "https://files.pythonhosted.org/packages/5a/84/e94227139ee5fb4d600a7a4927f322e1d4aea6fdc50bd3fca8493caba23f/cffi-1.17.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:805b4371bf7197c329fcb3ead37e710d1bca9da5d583f5073b799d5c5bd1eee4", size = 183178, upload-time = "2024-09-04T20:44:12.232Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/da/ee/fb72c2b48656111c4ef27f0f91da355e130a923473bf5ee75c5643d00cca/cffi-1.17.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:733e99bc2df47476e3848417c5a4540522f234dfd4ef3ab7fafdf555b082ec0c", size = 178840, upload-time = "2024-09-04T20:44:13.739Z" },
|
{ url = "https://files.pythonhosted.org/packages/da/ee/fb72c2b48656111c4ef27f0f91da355e130a923473bf5ee75c5643d00cca/cffi-1.17.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:733e99bc2df47476e3848417c5a4540522f234dfd4ef3ab7fafdf555b082ec0c", size = 178840, upload-time = "2024-09-04T20:44:13.739Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/cc/b6/db007700f67d151abadf508cbfd6a1884f57eab90b1bb985c4c8c02b0f28/cffi-1.17.1-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1257bdabf294dceb59f5e70c64a3e2f462c30c7ad68092d01bbbfb1c16b1ba36", size = 454803, upload-time = "2024-09-04T20:44:15.231Z" },
|
{ url = "https://files.pythonhosted.org/packages/cc/b6/db007700f67d151abadf508cbfd6a1884f57eab90b1bb985c4c8c02b0f28/cffi-1.17.1-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1257bdabf294dceb59f5e70c64a3e2f462c30c7ad68092d01bbbfb1c16b1ba36", size = 454803, upload-time = "2024-09-04T20:44:15.231Z" },
|
||||||
|
|
@ -106,15 +94,6 @@ version = "3.1.1"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/2f/ff/df5fede753cc10f6a5be0931204ea30c35fa2f2ea7a35b25bdaf4fe40e46/greenlet-3.1.1.tar.gz", hash = "sha256:4ce3ac6cdb6adf7946475d7ef31777c26d94bccc377e070a7986bd2d5c515467", size = 186022, upload-time = "2024-09-20T18:21:04.506Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/2f/ff/df5fede753cc10f6a5be0931204ea30c35fa2f2ea7a35b25bdaf4fe40e46/greenlet-3.1.1.tar.gz", hash = "sha256:4ce3ac6cdb6adf7946475d7ef31777c26d94bccc377e070a7986bd2d5c515467", size = 186022, upload-time = "2024-09-20T18:21:04.506Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/28/62/1c2665558618553c42922ed47a4e6d6527e2fa3516a8256c2f431c5d0441/greenlet-3.1.1-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:e4d333e558953648ca09d64f13e6d8f0523fa705f51cae3f03b5983489958c70", size = 272479, upload-time = "2024-09-20T17:07:22.332Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/76/9d/421e2d5f07285b6e4e3a676b016ca781f63cfe4a0cd8eaecf3fd6f7a71ae/greenlet-3.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fc016b73c94e98e29af67ab7b9a879c307c6731a2c9da0db5a7d9b7edd1159", size = 640404, upload-time = "2024-09-20T17:36:45.588Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/e5/de/6e05f5c59262a584e502dd3d261bbdd2c97ab5416cc9c0b91ea38932a901/greenlet-3.1.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d5e975ca70269d66d17dd995dafc06f1b06e8cb1ec1e9ed54c1d1e4a7c4cf26e", size = 652813, upload-time = "2024-09-20T17:39:19.052Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/49/93/d5f93c84241acdea15a8fd329362c2c71c79e1a507c3f142a5d67ea435ae/greenlet-3.1.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3b2813dc3de8c1ee3f924e4d4227999285fd335d1bcc0d2be6dc3f1f6a318ec1", size = 648517, upload-time = "2024-09-20T17:44:24.101Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/15/85/72f77fc02d00470c86a5c982b8daafdf65d38aefbbe441cebff3bf7037fc/greenlet-3.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e347b3bfcf985a05e8c0b7d462ba6f15b1ee1c909e2dcad795e49e91b152c383", size = 647831, upload-time = "2024-09-20T17:08:40.577Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f7/4b/1c9695aa24f808e156c8f4813f685d975ca73c000c2a5056c514c64980f6/greenlet-3.1.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e8f8c9cb53cdac7ba9793c276acd90168f416b9ce36799b9b885790f8ad6c0a", size = 602413, upload-time = "2024-09-20T17:08:31.728Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/76/70/ad6e5b31ef330f03b12559d19fda2606a522d3849cde46b24f223d6d1619/greenlet-3.1.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:62ee94988d6b4722ce0028644418d93a52429e977d742ca2ccbe1c4f4a792511", size = 1129619, upload-time = "2024-09-20T17:44:14.222Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/f4/fb/201e1b932e584066e0f0658b538e73c459b34d44b4bd4034f682423bc801/greenlet-3.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1776fd7f989fc6b8d8c8cb8da1f6b82c5814957264d1f6cf818d475ec2bf6395", size = 1155198, upload-time = "2024-09-20T17:09:23.903Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/12/da/b9ed5e310bb8b89661b80cbcd4db5a067903bbcd7fc854923f5ebb4144f0/greenlet-3.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:48ca08c771c268a768087b408658e216133aecd835c0ded47ce955381105ba39", size = 298930, upload-time = "2024-09-20T17:25:18.656Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/7d/ec/bad1ac26764d26aa1353216fcbfa4670050f66d445448aafa227f8b16e80/greenlet-3.1.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:4afe7ea89de619adc868e087b4d2359282058479d7cfb94970adf4b55284574d", size = 274260, upload-time = "2024-09-20T17:08:07.301Z" },
|
{ url = "https://files.pythonhosted.org/packages/7d/ec/bad1ac26764d26aa1353216fcbfa4670050f66d445448aafa227f8b16e80/greenlet-3.1.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:4afe7ea89de619adc868e087b4d2359282058479d7cfb94970adf4b55284574d", size = 274260, upload-time = "2024-09-20T17:08:07.301Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/66/d4/c8c04958870f482459ab5956c2942c4ec35cac7fe245527f1039837c17a9/greenlet-3.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f406b22b7c9a9b4f8aa9d2ab13d6ae0ac3e85c9a809bd590ad53fed2bf70dc79", size = 649064, upload-time = "2024-09-20T17:36:47.628Z" },
|
{ url = "https://files.pythonhosted.org/packages/66/d4/c8c04958870f482459ab5956c2942c4ec35cac7fe245527f1039837c17a9/greenlet-3.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f406b22b7c9a9b4f8aa9d2ab13d6ae0ac3e85c9a809bd590ad53fed2bf70dc79", size = 649064, upload-time = "2024-09-20T17:36:47.628Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/51/41/467b12a8c7c1303d20abcca145db2be4e6cd50a951fa30af48b6ec607581/greenlet-3.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c3a701fe5a9695b238503ce5bbe8218e03c3bcccf7e204e455e7462d770268aa", size = 663420, upload-time = "2024-09-20T17:39:21.258Z" },
|
{ url = "https://files.pythonhosted.org/packages/51/41/467b12a8c7c1303d20abcca145db2be4e6cd50a951fa30af48b6ec607581/greenlet-3.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c3a701fe5a9695b238503ce5bbe8218e03c3bcccf7e204e455e7462d770268aa", size = 663420, upload-time = "2024-09-20T17:39:21.258Z" },
|
||||||
|
|
@ -166,13 +145,6 @@ version = "0.19.0"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/cf/9b/95d8ce458462b8b71b8a70fa94563b2498b89933689f3a7b8911edfae3d7/msgspec-0.19.0.tar.gz", hash = "sha256:604037e7cd475345848116e89c553aa9a233259733ab51986ac924ab1b976f8e", size = 216934, upload-time = "2024-12-27T17:40:28.597Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/cf/9b/95d8ce458462b8b71b8a70fa94563b2498b89933689f3a7b8911edfae3d7/msgspec-0.19.0.tar.gz", hash = "sha256:604037e7cd475345848116e89c553aa9a233259733ab51986ac924ab1b976f8e", size = 216934, upload-time = "2024-12-27T17:40:28.597Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/24/d4/2ec2567ac30dab072cce3e91fb17803c52f0a37aab6b0c24375d2b20a581/msgspec-0.19.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:aa77046904db764b0462036bc63ef71f02b75b8f72e9c9dd4c447d6da1ed8f8e", size = 187939, upload-time = "2024-12-27T17:39:32.347Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/2b/c0/18226e4328897f4f19875cb62bb9259fe47e901eade9d9376ab5f251a929/msgspec-0.19.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:047cfa8675eb3bad68722cfe95c60e7afabf84d1bd8938979dd2b92e9e4a9551", size = 182202, upload-time = "2024-12-27T17:39:33.633Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/81/25/3a4b24d468203d8af90d1d351b77ea3cffb96b29492855cf83078f16bfe4/msgspec-0.19.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e78f46ff39a427e10b4a61614a2777ad69559cc8d603a7c05681f5a595ea98f7", size = 209029, upload-time = "2024-12-27T17:39:35.023Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/85/2e/db7e189b57901955239f7689b5dcd6ae9458637a9c66747326726c650523/msgspec-0.19.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c7adf191e4bd3be0e9231c3b6dc20cf1199ada2af523885efc2ed218eafd011", size = 210682, upload-time = "2024-12-27T17:39:36.384Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/03/97/7c8895c9074a97052d7e4a1cc1230b7b6e2ca2486714eb12c3f08bb9d284/msgspec-0.19.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:f04cad4385e20be7c7176bb8ae3dca54a08e9756cfc97bcdb4f18560c3042063", size = 214003, upload-time = "2024-12-27T17:39:39.097Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/61/61/e892997bcaa289559b4d5869f066a8021b79f4bf8e955f831b095f47a4cd/msgspec-0.19.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:45c8fb410670b3b7eb884d44a75589377c341ec1392b778311acdbfa55187716", size = 216833, upload-time = "2024-12-27T17:39:41.203Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/ce/3d/71b2dffd3a1c743ffe13296ff701ee503feaebc3f04d0e75613b6563c374/msgspec-0.19.0-cp311-cp311-win_amd64.whl", hash = "sha256:70eaef4934b87193a27d802534dc466778ad8d536e296ae2f9334e182ac27b6c", size = 186184, upload-time = "2024-12-27T17:39:43.702Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/b2/5f/a70c24f075e3e7af2fae5414c7048b0e11389685b7f717bb55ba282a34a7/msgspec-0.19.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f98bd8962ad549c27d63845b50af3f53ec468b6318400c9f1adfe8b092d7b62f", size = 190485, upload-time = "2024-12-27T17:39:44.974Z" },
|
{ url = "https://files.pythonhosted.org/packages/b2/5f/a70c24f075e3e7af2fae5414c7048b0e11389685b7f717bb55ba282a34a7/msgspec-0.19.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:f98bd8962ad549c27d63845b50af3f53ec468b6318400c9f1adfe8b092d7b62f", size = 190485, upload-time = "2024-12-27T17:39:44.974Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/89/b0/1b9763938cfae12acf14b682fcf05c92855974d921a5a985ecc197d1c672/msgspec-0.19.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:43bbb237feab761b815ed9df43b266114203f53596f9b6e6f00ebd79d178cdf2", size = 183910, upload-time = "2024-12-27T17:39:46.401Z" },
|
{ url = "https://files.pythonhosted.org/packages/89/b0/1b9763938cfae12acf14b682fcf05c92855974d921a5a985ecc197d1c672/msgspec-0.19.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:43bbb237feab761b815ed9df43b266114203f53596f9b6e6f00ebd79d178cdf2", size = 183910, upload-time = "2024-12-27T17:39:46.401Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/87/81/0c8c93f0b92c97e326b279795f9c5b956c5a97af28ca0fbb9fd86c83737a/msgspec-0.19.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4cfc033c02c3e0aec52b71710d7f84cb3ca5eb407ab2ad23d75631153fdb1f12", size = 210633, upload-time = "2024-12-27T17:39:49.099Z" },
|
{ url = "https://files.pythonhosted.org/packages/87/81/0c8c93f0b92c97e326b279795f9c5b956c5a97af28ca0fbb9fd86c83737a/msgspec-0.19.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4cfc033c02c3e0aec52b71710d7f84cb3ca5eb407ab2ad23d75631153fdb1f12", size = 210633, upload-time = "2024-12-27T17:39:49.099Z" },
|
||||||
|
|
@ -212,16 +184,16 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdbp"
|
name = "pdbp"
|
||||||
version = "1.6.1"
|
version = "1.8.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||||
{ name = "pygments" },
|
{ name = "pygments" },
|
||||||
{ name = "tabcompleter" },
|
{ name = "tabcompleter" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/69/13/80da03638f62facbee76312ca9ee5941c017b080f2e4c6919fd4e87e16e3/pdbp-1.6.1.tar.gz", hash = "sha256:f4041642952a05df89664e166d5bd379607a0866ddd753c06874f65552bdf40b", size = 25322, upload-time = "2024-11-07T15:36:43.062Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/50/91/2d614b0db12840d646159f65510415ade0db9db595d6dee3eac60dfe9302/pdbp-1.8.2.tar.gz", hash = "sha256:367c25c17555d3ac1f024b9ad494ff50e6e20f6494a84741487f3e6596d88f94", size = 25843, upload-time = "2026-01-14T03:10:28.134Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/29/93/d56fb9ba5569dc29d8263c72e46d21a2fd38741339ebf03f54cf7561828c/pdbp-1.6.1-py3-none-any.whl", hash = "sha256:f10bad2ee044c0e5c168cb0825abfdbdc01c50013e9755df5261b060bdd35c22", size = 21495, upload-time = "2024-11-07T15:36:41.061Z" },
|
{ url = "https://files.pythonhosted.org/packages/51/fe/53ac0cd932db5dcaf55961bc7cb7afdca8d80d8cc7406ed661f0c7dc111a/pdbp-1.8.2-py3-none-any.whl", hash = "sha256:d4fd05e177636b5ccd0b2e03e378cec57afc06149e5fd975de6f8ddb3d0109a8", size = 21969, upload-time = "2026-01-14T03:10:27.062Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -236,6 +208,15 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" },
|
{ url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "platformdirs"
|
||||||
|
version = "4.4.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/23/e8/21db9c9987b0e728855bd57bff6984f67952bea55d6f75e055c46b5383e8/platformdirs-4.4.0.tar.gz", hash = "sha256:ca753cf4d81dc309bc67b0ea38fd15dc97bc30ce419a7f58d13eb3bf14c4febf", size = 21634, upload-time = "2025-08-26T14:32:04.268Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/40/4b/2028861e724d3bd36227adfa20d3fd24c3fc6d52032f4a93c133be5d17ce/platformdirs-4.4.0-py3-none-any.whl", hash = "sha256:abd01743f24e5287cd7a5db3752faf1a2d65353f38ec26d98e25a6db65958c85", size = 18654, upload-time = "2025-08-26T14:32:02.735Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pluggy"
|
name = "pluggy"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|
@ -292,11 +273,11 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pygments"
|
name = "pygments"
|
||||||
version = "2.19.1"
|
version = "2.19.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581, upload-time = "2025-01-06T17:26:30.443Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload-time = "2025-01-06T17:26:25.553Z" },
|
{ url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -404,6 +385,7 @@ dependencies = [
|
||||||
{ name = "colorlog" },
|
{ name = "colorlog" },
|
||||||
{ name = "msgspec" },
|
{ name = "msgspec" },
|
||||||
{ name = "pdbp" },
|
{ name = "pdbp" },
|
||||||
|
{ name = "platformdirs" },
|
||||||
{ name = "tricycle" },
|
{ name = "tricycle" },
|
||||||
{ name = "trio" },
|
{ name = "trio" },
|
||||||
{ name = "wrapt" },
|
{ name = "wrapt" },
|
||||||
|
|
@ -446,7 +428,8 @@ requires-dist = [
|
||||||
{ name = "cffi", specifier = ">=1.17.1" },
|
{ name = "cffi", specifier = ">=1.17.1" },
|
||||||
{ name = "colorlog", specifier = ">=6.8.2,<7" },
|
{ name = "colorlog", specifier = ">=6.8.2,<7" },
|
||||||
{ name = "msgspec", specifier = ">=0.19.0" },
|
{ name = "msgspec", specifier = ">=0.19.0" },
|
||||||
{ name = "pdbp", specifier = ">=1.6,<2" },
|
{ name = "pdbp", specifier = ">=1.8.2,<2" },
|
||||||
|
{ name = "platformdirs", specifier = ">=4.4.0" },
|
||||||
{ name = "tricycle", specifier = ">=0.4.1,<0.5" },
|
{ name = "tricycle", specifier = ">=0.4.1,<0.5" },
|
||||||
{ name = "trio", specifier = ">0.27" },
|
{ name = "trio", specifier = ">0.27" },
|
||||||
{ name = "wrapt", specifier = ">=1.16.0,<2" },
|
{ name = "wrapt", specifier = ">=1.16.0,<2" },
|
||||||
|
|
@ -462,7 +445,7 @@ dev = [
|
||||||
{ name = "pytest", specifier = ">=8.3.5" },
|
{ name = "pytest", specifier = ">=8.3.5" },
|
||||||
{ name = "stackscope", specifier = ">=0.2.2,<0.3" },
|
{ name = "stackscope", specifier = ">=0.2.2,<0.3" },
|
||||||
{ name = "typing-extensions", specifier = ">=4.14.1" },
|
{ name = "typing-extensions", specifier = ">=4.14.1" },
|
||||||
{ name = "xonsh", specifier = ">=0.19.2" },
|
{ name = "xonsh", specifier = ">=0.22.2" },
|
||||||
]
|
]
|
||||||
devx = [
|
devx = [
|
||||||
{ name = "greenback", specifier = ">=1.2.1,<2" },
|
{ name = "greenback", specifier = ">=1.2.1,<2" },
|
||||||
|
|
@ -474,7 +457,7 @@ repl = [
|
||||||
{ name = "prompt-toolkit", specifier = ">=3.0.50" },
|
{ name = "prompt-toolkit", specifier = ">=3.0.50" },
|
||||||
{ name = "psutil", specifier = ">=7.0.0" },
|
{ name = "psutil", specifier = ">=7.0.0" },
|
||||||
{ name = "pyperclip", specifier = ">=1.9.0" },
|
{ name = "pyperclip", specifier = ">=1.9.0" },
|
||||||
{ name = "xonsh", specifier = ">=0.19.2" },
|
{ name = "xonsh", specifier = ">=0.22.2" },
|
||||||
]
|
]
|
||||||
testing = [
|
testing = [
|
||||||
{ name = "pexpect", specifier = ">=4.9.0,<5" },
|
{ name = "pexpect", specifier = ">=4.9.0,<5" },
|
||||||
|
|
@ -534,17 +517,6 @@ version = "1.17.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/c3/fc/e91cc220803d7bc4db93fb02facd8461c37364151b8494762cc88b0fbcef/wrapt-1.17.2.tar.gz", hash = "sha256:41388e9d4d1522446fe79d3213196bd9e3b301a336965b9e27ca2788ebd122f3", size = 55531, upload-time = "2025-01-14T10:35:45.465Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/c3/fc/e91cc220803d7bc4db93fb02facd8461c37364151b8494762cc88b0fbcef/wrapt-1.17.2.tar.gz", hash = "sha256:41388e9d4d1522446fe79d3213196bd9e3b301a336965b9e27ca2788ebd122f3", size = 55531, upload-time = "2025-01-14T10:35:45.465Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/cd/f7/a2aab2cbc7a665efab072344a8949a71081eed1d2f451f7f7d2b966594a2/wrapt-1.17.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ff04ef6eec3eee8a5efef2401495967a916feaa353643defcc03fc74fe213b58", size = 53308, upload-time = "2025-01-14T10:33:33.992Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/50/ff/149aba8365fdacef52b31a258c4dc1c57c79759c335eff0b3316a2664a64/wrapt-1.17.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4db983e7bca53819efdbd64590ee96c9213894272c776966ca6306b73e4affda", size = 38488, upload-time = "2025-01-14T10:33:35.264Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/65/46/5a917ce85b5c3b490d35c02bf71aedaa9f2f63f2d15d9949cc4ba56e8ba9/wrapt-1.17.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9abc77a4ce4c6f2a3168ff34b1da9b0f311a8f1cfd694ec96b0603dff1c79438", size = 38776, upload-time = "2025-01-14T10:33:38.28Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/ca/74/336c918d2915a4943501c77566db41d1bd6e9f4dbc317f356b9a244dfe83/wrapt-1.17.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b929ac182f5ace000d459c59c2c9c33047e20e935f8e39371fa6e3b85d56f4a", size = 83776, upload-time = "2025-01-14T10:33:40.678Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/09/99/c0c844a5ccde0fe5761d4305485297f91d67cf2a1a824c5f282e661ec7ff/wrapt-1.17.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f09b286faeff3c750a879d336fb6d8713206fc97af3adc14def0cdd349df6000", size = 75420, upload-time = "2025-01-14T10:33:41.868Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/b4/b0/9fc566b0fe08b282c850063591a756057c3247b2362b9286429ec5bf1721/wrapt-1.17.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a7ed2d9d039bd41e889f6fb9364554052ca21ce823580f6a07c4ec245c1f5d6", size = 83199, upload-time = "2025-01-14T10:33:43.598Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/9d/4b/71996e62d543b0a0bd95dda485219856def3347e3e9380cc0d6cf10cfb2f/wrapt-1.17.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:129a150f5c445165ff941fc02ee27df65940fcb8a22a61828b1853c98763a64b", size = 82307, upload-time = "2025-01-14T10:33:48.499Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/39/35/0282c0d8789c0dc9bcc738911776c762a701f95cfe113fb8f0b40e45c2b9/wrapt-1.17.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:1fb5699e4464afe5c7e65fa51d4f99e0b2eadcc176e4aa33600a3df7801d6662", size = 75025, upload-time = "2025-01-14T10:33:51.191Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/4f/6d/90c9fd2c3c6fee181feecb620d95105370198b6b98a0770cba090441a828/wrapt-1.17.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9a2bce789a5ea90e51a02dfcc39e31b7f1e662bc3317979aa7e5538e3a034f72", size = 81879, upload-time = "2025-01-14T10:33:52.328Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/8f/fa/9fb6e594f2ce03ef03eddbdb5f4f90acb1452221a5351116c7c4708ac865/wrapt-1.17.2-cp311-cp311-win32.whl", hash = "sha256:4afd5814270fdf6380616b321fd31435a462019d834f83c8611a0ce7484c7317", size = 36419, upload-time = "2025-01-14T10:33:53.551Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/47/f8/fb1773491a253cbc123c5d5dc15c86041f746ed30416535f2a8df1f4a392/wrapt-1.17.2-cp311-cp311-win_amd64.whl", hash = "sha256:acc130bc0375999da18e3d19e5a86403667ac0c4042a094fefb7eec8ebac7cf3", size = 38773, upload-time = "2025-01-14T10:33:56.323Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/a1/bd/ab55f849fd1f9a58ed7ea47f5559ff09741b25f00c191231f9f059c83949/wrapt-1.17.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:d5e2439eecc762cd85e7bd37161d4714aa03a33c5ba884e26c81559817ca0925", size = 53799, upload-time = "2025-01-14T10:33:57.4Z" },
|
{ url = "https://files.pythonhosted.org/packages/a1/bd/ab55f849fd1f9a58ed7ea47f5559ff09741b25f00c191231f9f059c83949/wrapt-1.17.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:d5e2439eecc762cd85e7bd37161d4714aa03a33c5ba884e26c81559817ca0925", size = 53799, upload-time = "2025-01-14T10:33:57.4Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/53/18/75ddc64c3f63988f5a1d7e10fb204ffe5762bc663f8023f18ecaf31a332e/wrapt-1.17.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fc7cb4c1c744f8c05cd5f9438a3caa6ab94ce8344e952d7c45a8ed59dd88392", size = 38821, upload-time = "2025-01-14T10:33:59.334Z" },
|
{ url = "https://files.pythonhosted.org/packages/53/18/75ddc64c3f63988f5a1d7e10fb204ffe5762bc663f8023f18ecaf31a332e/wrapt-1.17.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fc7cb4c1c744f8c05cd5f9438a3caa6ab94ce8344e952d7c45a8ed59dd88392", size = 38821, upload-time = "2025-01-14T10:33:59.334Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/48/2a/97928387d6ed1c1ebbfd4efc4133a0633546bec8481a2dd5ec961313a1c7/wrapt-1.17.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8fdbdb757d5390f7c675e558fd3186d590973244fab0c5fe63d373ade3e99d40", size = 38919, upload-time = "2025-01-14T10:34:04.093Z" },
|
{ url = "https://files.pythonhosted.org/packages/48/2a/97928387d6ed1c1ebbfd4efc4133a0633546bec8481a2dd5ec961313a1c7/wrapt-1.17.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8fdbdb757d5390f7c675e558fd3186d590973244fab0c5fe63d373ade3e99d40", size = 38919, upload-time = "2025-01-14T10:34:04.093Z" },
|
||||||
|
|
@ -583,13 +555,11 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xonsh"
|
name = "xonsh"
|
||||||
version = "0.19.2"
|
version = "0.22.4"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/68/4e/56e95a5e607eb3b0da37396f87cde70588efc8ef819ab16f02d5b8378dc4/xonsh-0.19.2.tar.gz", hash = "sha256:cfdd0680d954a2c3aefd6caddcc7143a3d06aa417ed18365a08219bb71b960b0", size = 799960, upload-time = "2025-02-11T17:10:43.563Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/48/df/1fc9ed62b3d7c14612e1713e9eb7bd41d54f6ad1028a8fbb6b7cddebc345/xonsh-0.22.4.tar.gz", hash = "sha256:6be346563fec2db75778ba5d2caee155525e634e99d9cc8cc347626025c0b3fa", size = 826665, upload-time = "2026-02-17T07:53:39.424Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/6c/13/281094759df87b23b3c02dc4a16603ab08ea54d7f6acfeb69f3341137c7a/xonsh-0.19.2-py310-none-any.whl", hash = "sha256:ec7f163fd3a4943782aa34069d4e72793328c916a5975949dbec8536cbfc089b", size = 642301, upload-time = "2025-02-11T17:10:39.244Z" },
|
{ url = "https://files.pythonhosted.org/packages/2e/00/7cbc0c1fb64365a0a317c54ce3a151c9644eea5a509d9cbaae61c9fd1426/xonsh-0.22.4-py311-none-any.whl", hash = "sha256:38b29b29fa85aa756462d9d9bbcaa1d85478c2108da3de6cc590a69a4bcd1a01", size = 654375, upload-time = "2026-02-17T07:53:37.702Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/29/41/a51e4c3918fe9a293b150cb949b1b8c6d45eb17dfed480dcb76ea43df4e7/xonsh-0.19.2-py311-none-any.whl", hash = "sha256:53c45f7a767901f2f518f9b8dd60fc653e0498e56e89825e1710bb0859985049", size = 642286, upload-time = "2025-02-11T17:10:41.678Z" },
|
{ url = "https://files.pythonhosted.org/packages/2e/c2/3dd498dc28d8f89cdd52e39950c5e591499ae423f61694c0bb4d03ed1d82/xonsh-0.22.4-py312-none-any.whl", hash = "sha256:4e538fac9f4c3d866ddbdeca068f0c0515469c997ed58d3bfee963878c6df5a5", size = 654300, upload-time = "2026-02-17T07:53:35.813Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/0a/93/9a77b731f492fac27c577dea2afb5a2bcc2a6a1c79be0c86c95498060270/xonsh-0.19.2-py312-none-any.whl", hash = "sha256:b24c619aa52b59eae4d35c4195dba9b19a2c548fb5c42c6f85f2b8ccb96807b5", size = 642386, upload-time = "2025-02-11T17:10:43.688Z" },
|
{ url = "https://files.pythonhosted.org/packages/82/7d/1f9c7147518e9f03f6ce081b5bfc4f1aceb6ec5caba849024d005e41d3be/xonsh-0.22.4-py313-none-any.whl", hash = "sha256:cc5fabf0ad0c56a2a11bed1e6a43c4ec6416a5b30f24f126b8e768547c3793e2", size = 654818, upload-time = "2026-02-17T07:53:33.477Z" },
|
||||||
{ url = "https://files.pythonhosted.org/packages/be/75/070324769c1ff88d971ce040f4f486339be98e0a365c8dd9991eb654265b/xonsh-0.19.2-py313-none-any.whl", hash = "sha256:c53ef6c19f781fbc399ed1b382b5c2aac2125010679a3b61d643978273c27df0", size = 642873, upload-time = "2025-02-11T17:10:39.297Z" },
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/fa/cb/2c7ccec54f5b0e73fdf7650e8336582ff0347d9001c5ef8271dc00c034fe/xonsh-0.19.2-py39-none-any.whl", hash = "sha256:bcc0225dc3847f1ed2f175dac6122fbcc54cea67d9c2dc2753d9615e2a5ff284", size = 634602, upload-time = "2025-02-11T17:10:37.004Z" },
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue