You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c06bc8f
Browse filesBrowse the repository at this point in the historyBrowse files
- Ruff config: `select` includes E,W,F,I,S,D,UP,B,C; `ignore` includes `B904`, `D1`, `E501`, `S101` (so `assert` in tests is fine, and missing docstrings on private members are allowed).
41
-
- Docstrings use `pep257` convention: present-tense imperative, start with capital, end with period, describe external behavior only. Class docstrings must not repeat the class name or start with a verb.
42
-
- Prefer generators over building lists/arrays, `match`/`switch` over `if` chains, EAFP over LBYL, dataclasses for plain data, context managers for resources, walrus `:=` when it aids readability.
43
-
- Avoid code comments except for third-party behavior or complex algorithms. Avoid nested functions and loops-in-loops where a generator/recursion works.
44
-
- Do not add dependencies unless widely adopted and well-maintained; prefer BSD/MIT-style permissive licenses.
40
+
- NEVER format code, tests, or docs manually. MUST USE `prek run --all-files`.
- Integration point for queue authors: `threadmill/backends.py` (`AcknowledgeableTaskBackend`) — subclasses implement `acquire` (lock-without-remove) and `acknowledge` (remove + publish). Requires late-ack support from the underlying queue.
60
56
- Test app backend `tests/testapp/backends.py` (`GeneratingTaskBackend`) generates tasks in-process for benchmarks; reset between runs via `default_task_backend.reset()`.
Optionally, install the inspector dependency if you want the TUI:
65
65
66
66
```console
67
-
uv run manage.py threadmill
67
+
uv add threadmill[inspector]
68
+
```
69
+
70
+
Then launch the worker pool:
71
+
72
+
```console
73
+
uv run manage.py threadmill worker
68
74
```
69
75
70
76
## Usage
@@ -79,15 +85,15 @@ Depending on your workload, you can tweak the number of processes and threads.
79
85
Processes allow for parallel compute (no GIL) while threads are great for low-memory concurrent IO.
80
86
81
87
```console
82
-
uv run manage.py threadmill --processes 4 --threads 2
88
+
uv run manage.py threadmill worker --processes 4 --threads 2
83
89
```
84
90
85
91
#### Health
86
92
87
93
If your tasks leak memory, you can recycle (restart) the workers after a certain number of tasks have been processed:
88
94
89
95
```console
90
-
uv run manage.py threadmill --max-tasks 1000 --max-tasks-jitter 100
96
+
uv run manage.py threadmill worker --max-tasks 1000 --max-tasks-jitter 100
91
97
```
92
98
93
99
This will restart the workers after 1000 tasks have been processed, with a random jitter of up to 100 tasks to avoid all workers restarting at the same time.
@@ -102,6 +108,18 @@ All workers will finish the tasks they acquired and acknowledge them.
102
108
You can use `--exit-empty` to exit immediately after all tasks have been processed,
103
109
which might be useful for draining a one-off queue.
0 commit comments