localqueue 1.0.1__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {localqueue-1.0.1 → localqueue-1.1.0}/.github/workflows/ci.yml +4 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/.github/workflows/wheels.yml +76 -21
- localqueue-1.1.0/CHANGELOG.md +85 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/Cargo.lock +1 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/Cargo.toml +4 -1
- localqueue-1.1.0/LICENSE +202 -0
- localqueue-1.0.1/README.md → localqueue-1.1.0/PKG-INFO +115 -6
- localqueue-1.0.1/PKG-INFO → localqueue-1.1.0/README.md +87 -21
- {localqueue-1.0.1 → localqueue-1.1.0}/benchmarks/README.md +2 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/benchmarks/queue_bench.py +154 -16
- localqueue-1.1.0/docs/event-bus.md +213 -0
- localqueue-1.1.0/docs/guarantees.md +79 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/pyproject.toml +15 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/__init__.py +3 -2
- localqueue-1.1.0/python/localqueue/bus/__init__.py +25 -0
- localqueue-1.1.0/python/localqueue/bus/bus.py +300 -0
- localqueue-1.1.0/python/localqueue/bus/consumer.py +175 -0
- localqueue-1.1.0/python/localqueue/bus/event.py +46 -0
- localqueue-1.1.0/python/localqueue/bus/registry.py +37 -0
- localqueue-1.1.0/python/localqueue/bus/subscription.py +33 -0
- localqueue-1.1.0/python/localqueue/bus/topology.py +103 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/core.py +95 -69
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/exceptions.py +1 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/job.py +4 -4
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/localqueue.pyi +11 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/python/localqueue/worker.py +38 -38
- {localqueue-1.0.1 → localqueue-1.1.0}/src/error.rs +11 -11
- {localqueue-1.0.1 → localqueue-1.1.0}/src/lib.rs +1 -1
- {localqueue-1.0.1 → localqueue-1.1.0}/src/queue.rs +87 -65
- localqueue-1.1.0/src/storage.rs +277 -0
- localqueue-1.1.0/tests/test_batch.py +145 -0
- localqueue-1.1.0/tests/test_bus.py +779 -0
- localqueue-1.1.0/tests/test_bus_static_topology.py +332 -0
- localqueue-1.1.0/tests/test_bus_topology.py +82 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_concurrency.py +84 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_core.py +22 -2
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_gil.py +38 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_worker.py +14 -0
- localqueue-1.0.1/docs/guarantees.md +0 -80
- localqueue-1.0.1/src/storage.rs +0 -72
- {localqueue-1.0.1 → localqueue-1.1.0}/.github/workflows/stress.yml +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/.gitignore +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/docs/internal/initial_idea.md +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/examples/basic.py +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/src/schema.rs +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/stress/run_soak.py +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/__init__.py +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_contract.py +0 -0
- {localqueue-1.0.1 → localqueue-1.1.0}/tests/test_maintenance.py +0 -0
|
@@ -90,7 +90,10 @@ jobs:
|
|
|
90
90
|
else
|
|
91
91
|
source .venv/bin/activate
|
|
92
92
|
fi
|
|
93
|
-
python -m pip install --upgrade
|
|
93
|
+
python -m pip install --upgrade \
|
|
94
|
+
"maturin>=1.14,<2" \
|
|
95
|
+
"pytest>=8,<10" \
|
|
96
|
+
"pydantic>=2,<3"
|
|
94
97
|
maturin develop --release --locked
|
|
95
98
|
pytest -ra
|
|
96
99
|
|
|
@@ -36,10 +36,6 @@ jobs:
|
|
|
36
36
|
target: x86_64-pc-windows-msvc
|
|
37
37
|
manylinux: off
|
|
38
38
|
runs-on: ${{ matrix.os }}
|
|
39
|
-
environment: pypi
|
|
40
|
-
permissions:
|
|
41
|
-
contents: read
|
|
42
|
-
id-token: write
|
|
43
39
|
steps:
|
|
44
40
|
- name: Check out repository
|
|
45
41
|
uses: actions/checkout@v6
|
|
@@ -75,7 +71,9 @@ jobs:
|
|
|
75
71
|
- name: Install one wheel for smoke testing
|
|
76
72
|
if: matrix.name != 'linux-aarch64'
|
|
77
73
|
shell: bash
|
|
78
|
-
run:
|
|
74
|
+
run: |
|
|
75
|
+
python -m pip install --upgrade "pydantic>=2,<3"
|
|
76
|
+
python -m pip install --force-reinstall --no-index target/wheels/*cp313*.whl
|
|
79
77
|
|
|
80
78
|
- name: Smoke-test installed wheel outside the checkout
|
|
81
79
|
if: matrix.name != 'linux-aarch64'
|
|
@@ -85,15 +83,36 @@ jobs:
|
|
|
85
83
|
python - <<'PY'
|
|
86
84
|
import tempfile
|
|
87
85
|
|
|
88
|
-
from localqueue import SimpleQueue
|
|
86
|
+
from localqueue import EnqueueItem, SimpleQueue
|
|
87
|
+
from localqueue.bus import BaseEvent, BusTopology, EventBus
|
|
88
|
+
|
|
89
|
+
class WheelEvent(BaseEvent):
|
|
90
|
+
value: int
|
|
89
91
|
|
|
90
92
|
with tempfile.TemporaryDirectory() as path:
|
|
91
93
|
queue = SimpleQueue(path)
|
|
92
|
-
queue.
|
|
94
|
+
queue.put_many([
|
|
95
|
+
{"platform": "wheel"},
|
|
96
|
+
EnqueueItem({"platform": "batch"}, job_id="batch-1"),
|
|
97
|
+
])
|
|
98
|
+
job = queue.get(block=False)
|
|
99
|
+
queue.ack(job)
|
|
93
100
|
job = queue.get(block=False)
|
|
94
101
|
queue.ack(job)
|
|
95
|
-
assert queue.stats()["acked"] ==
|
|
102
|
+
assert queue.stats()["acked"] == 2
|
|
96
103
|
queue.close()
|
|
104
|
+
|
|
105
|
+
topology = BusTopology({"smoke": [WheelEvent]})
|
|
106
|
+
bus = EventBus(path, topology=topology)
|
|
107
|
+
smoke = bus.subscription("smoke")
|
|
108
|
+
|
|
109
|
+
@smoke.handler(WheelEvent)
|
|
110
|
+
def handle(event: WheelEvent) -> None:
|
|
111
|
+
assert event.value == 1
|
|
112
|
+
|
|
113
|
+
receipt = bus.dispatch(WheelEvent(value=1))
|
|
114
|
+
assert receipt.subscriptions == ("smoke",)
|
|
115
|
+
bus.close()
|
|
97
116
|
PY
|
|
98
117
|
|
|
99
118
|
- name: Validate Linux ARM64 wheel artifact
|
|
@@ -101,18 +120,54 @@ jobs:
|
|
|
101
120
|
shell: bash
|
|
102
121
|
run: test -n "$(find target/wheels -name '*cp313*.whl' -print -quit)"
|
|
103
122
|
|
|
104
|
-
- name:
|
|
105
|
-
if:
|
|
106
|
-
|
|
123
|
+
- name: Build source distribution
|
|
124
|
+
if: matrix.name == 'linux-x86_64'
|
|
125
|
+
uses: PyO3/maturin-action@v1
|
|
126
|
+
with:
|
|
127
|
+
command: sdist
|
|
128
|
+
args: --out target/dist
|
|
129
|
+
maturin-version: v1.14.1
|
|
107
130
|
|
|
108
|
-
- name:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
- name: Upload wheels
|
|
132
|
+
uses: actions/upload-artifact@v4
|
|
133
|
+
with:
|
|
134
|
+
name: wheels-${{ matrix.name }}
|
|
135
|
+
path: target/wheels/*.whl
|
|
136
|
+
if-no-files-found: error
|
|
114
137
|
|
|
115
|
-
- name:
|
|
116
|
-
if:
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
- name: Upload source distribution
|
|
139
|
+
if: matrix.name == 'linux-x86_64'
|
|
140
|
+
uses: actions/upload-artifact@v4
|
|
141
|
+
with:
|
|
142
|
+
name: source-distribution
|
|
143
|
+
path: target/dist/*.tar.gz
|
|
144
|
+
if-no-files-found: error
|
|
145
|
+
|
|
146
|
+
publish:
|
|
147
|
+
name: Publish complete release to PyPI
|
|
148
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
149
|
+
needs: build
|
|
150
|
+
runs-on: ubuntu-latest
|
|
151
|
+
environment: pypi
|
|
152
|
+
permissions:
|
|
153
|
+
contents: read
|
|
154
|
+
id-token: write
|
|
155
|
+
steps:
|
|
156
|
+
- name: Download all release artifacts
|
|
157
|
+
uses: actions/download-artifact@v4
|
|
158
|
+
with:
|
|
159
|
+
pattern: wheels-*
|
|
160
|
+
path: target/dist
|
|
161
|
+
merge-multiple: true
|
|
162
|
+
|
|
163
|
+
- name: Download source distribution
|
|
164
|
+
uses: actions/download-artifact@v4
|
|
165
|
+
with:
|
|
166
|
+
name: source-distribution
|
|
167
|
+
path: target/dist
|
|
168
|
+
|
|
169
|
+
- name: Install uv
|
|
170
|
+
uses: astral-sh/setup-uv@v8
|
|
171
|
+
|
|
172
|
+
- name: Publish all artifacts
|
|
173
|
+
run: uv publish --trusted-publishing always target/dist/*
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `localqueue` are documented here.
|
|
4
|
+
|
|
5
|
+
## [1.1.0] - 2026-07-21
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `SimpleQueue.put_many(...)` for atomic batch enqueueing, with optional
|
|
10
|
+
per-item deduplication through `EnqueueItem`.
|
|
11
|
+
- The optional `localqueue.bus` package, exposing `BaseEvent` and `EventBus`
|
|
12
|
+
when installed with `localqueue[bus]`.
|
|
13
|
+
- Atomic event fan-out to durable subscriptions, wildcard handlers, consumer
|
|
14
|
+
groups across processes, lease heartbeats, retries, and dead-letter handling.
|
|
15
|
+
- Fan-out benchmarks and multiprocess coverage for the event bus.
|
|
16
|
+
- Event routing now uses an explicit static `BusTopology`, allowing producers
|
|
17
|
+
and consumers to run in separate processes without producers importing
|
|
18
|
+
consumer handlers.
|
|
19
|
+
- Handler registration is separate from subscription declaration through
|
|
20
|
+
`bus.subscription(...).handler(...)`.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Blocking queue operations and synchronous event handlers are moved off the
|
|
25
|
+
asyncio event loop.
|
|
26
|
+
- Idle polling avoids repeated SQLite writer transactions while queues are
|
|
27
|
+
empty, reducing lock contention across many idle subscriptions.
|
|
28
|
+
- Public docstrings, log messages, validation errors, and native queue errors
|
|
29
|
+
are now consistently written in English.
|
|
30
|
+
- Release wheels cover CPython 3.10 through 3.14 on Linux x86-64/aarch64,
|
|
31
|
+
macOS x86-64/arm64, and Windows x86-64.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Reject worker heartbeat intervals that are not shorter than the queue lease,
|
|
36
|
+
non-positive lease extensions, and negative NACK delays.
|
|
37
|
+
|
|
38
|
+
### Compatibility
|
|
39
|
+
|
|
40
|
+
- Existing `SimpleQueue` and `Worker` APIs remain backward compatible.
|
|
41
|
+
- Event bus support is optional and requires Pydantic 2 via the `bus` extra.
|
|
42
|
+
|
|
43
|
+
## Migrating from 0.5.0
|
|
44
|
+
|
|
45
|
+
Version 1.0.0 was a complete, backward-incompatible reimplementation of the
|
|
46
|
+
legacy `localqueue` package. Upgrading from 0.5.0 is not an in-place library or
|
|
47
|
+
storage migration:
|
|
48
|
+
|
|
49
|
+
- Replace `PersistentQueue` with `SimpleQueue` and adapt producers and
|
|
50
|
+
consumers to the explicit `put` → `get` → `ack`/`nack` lifecycle.
|
|
51
|
+
- The Tenacity-backed persistent retry API and the `cli`, `lmdb`, and `sqlite`
|
|
52
|
+
extras from 0.5.0 are not part of 1.x. Version 1.x uses its bundled SQLite
|
|
53
|
+
engine and Rust extension; install `localqueue[bus]` only when the event bus
|
|
54
|
+
is needed.
|
|
55
|
+
- Do not reuse a 0.5.0 database with 1.x. Drain or export pending work with
|
|
56
|
+
0.5.0 first, create a new 1.x queue directory, and enqueue any work that must
|
|
57
|
+
be retained.
|
|
58
|
+
- Imports, configuration, storage layout, and operational commands from 0.5.0
|
|
59
|
+
are not guaranteed to work in 1.x. Test the migration in a separate virtual
|
|
60
|
+
environment before replacing a production worker.
|
|
61
|
+
- Version 1.x supports Python 3.10 and newer and is licensed under Apache-2.0;
|
|
62
|
+
version 0.5.0 required Python 3.11 and used the MIT license.
|
|
63
|
+
|
|
64
|
+
## [1.0.1] - 2026-07-20
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- Expanded the public README with installation, delivery guarantees,
|
|
69
|
+
configuration, API, architecture, and development guidance.
|
|
70
|
+
- Declared and validated support for Python 3.10 through 3.14 across Linux,
|
|
71
|
+
macOS, and Windows wheels.
|
|
72
|
+
|
|
73
|
+
## [1.0.0] - 2026-07-20
|
|
74
|
+
|
|
75
|
+
### Changed
|
|
76
|
+
|
|
77
|
+
- Reimplemented `localqueue` around `SimpleQueue`, a bundled SQLite database,
|
|
78
|
+
and a native Rust extension.
|
|
79
|
+
- Replaced the legacy 0.5.0 API and storage model with explicit ACK/NACK,
|
|
80
|
+
leases, bounded retries, dead-letter handling, receipt fencing, and
|
|
81
|
+
multiprocess safety on one machine.
|
|
82
|
+
|
|
83
|
+
[1.1.0]: https://github.com/brunoportis/localqueue/compare/v1.0.1...v1.1.0
|
|
84
|
+
[1.0.1]: https://github.com/brunoportis/localqueue/compare/v1.0.0...v1.0.1
|
|
85
|
+
[1.0.0]: https://github.com/brunoportis/localqueue/releases/tag/v1.0.0
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "localqueue"
|
|
3
|
-
version = "1.0
|
|
3
|
+
version = "1.1.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
rust-version = "1.83"
|
|
6
|
+
description = "A persistent, multiprocess-safe local queue for Python, backed by SQLite and Rust."
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
repository = "https://github.com/brunoportis/localqueue"
|
|
6
9
|
readme = "README.md"
|
|
7
10
|
|
|
8
11
|
[lib]
|
localqueue-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: localqueue
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Requires-Dist: persist-queue==1.1.0 ; extra == 'benchmark'
|
|
11
|
+
Requires-Dist: pydantic>=2,<3 ; extra == 'bus'
|
|
12
|
+
Requires-Dist: pytest>=8.0 ; extra == 'dev'
|
|
13
|
+
Requires-Dist: maturin>=1.14 ; extra == 'dev'
|
|
14
|
+
Requires-Dist: pydantic>=2,<3 ; extra == 'dev'
|
|
15
|
+
Provides-Extra: benchmark
|
|
16
|
+
Provides-Extra: bus
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Summary: A persistent, multiprocess-safe local queue for Python, backed by SQLite and Rust.
|
|
20
|
+
License-Expression: Apache-2.0
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
23
|
+
Project-URL: Homepage, https://github.com/brunoportis/localqueue
|
|
24
|
+
Project-URL: Issues, https://github.com/brunoportis/localqueue/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/brunoportis/localqueue
|
|
26
|
+
|
|
1
27
|
# localqueue
|
|
2
28
|
|
|
3
29
|
[](https://pypi.org/project/localqueue/)
|
|
4
30
|
[](https://pypi.org/project/localqueue/)
|
|
5
31
|
[](https://github.com/brunoportis/localqueue/actions/workflows/ci.yml)
|
|
32
|
+
[](https://github.com/brunoportis/localqueue/blob/main/LICENSE)
|
|
6
33
|
|
|
7
34
|
A persistent, multiprocess-safe local queue for Python, backed by SQLite and Rust.
|
|
8
35
|
|
|
@@ -19,10 +46,14 @@ service.
|
|
|
19
46
|
acknowledge a newer delivery.
|
|
20
47
|
- **Flexible:** use multiple named queues, optional job deduplication, automatic
|
|
21
48
|
worker heartbeats, and custom serializers.
|
|
49
|
+
- **Event-driven:** optional durable pub/sub with explicit static topology,
|
|
50
|
+
atomic fan-out, consumer groups, retries, and dead-letter handling.
|
|
22
51
|
|
|
23
52
|
[Installation](#installation) · [Quick start](#quick-start) ·
|
|
24
|
-
[Worker](#worker) · [
|
|
25
|
-
[
|
|
53
|
+
[Worker](#worker) · [Event bus](#event-bus) ·
|
|
54
|
+
[Guarantees](#delivery-guarantees) ·
|
|
55
|
+
[API](#api-overview) · [Changelog](CHANGELOG.md) ·
|
|
56
|
+
[Development](#development)
|
|
26
57
|
|
|
27
58
|
## Installation
|
|
28
59
|
|
|
@@ -40,6 +71,10 @@ python -m pip install localqueue
|
|
|
40
71
|
|
|
41
72
|
`localqueue` requires Python 3.10 or newer.
|
|
42
73
|
|
|
74
|
+
Upgrading from 0.5.0 requires code and storage changes because 1.x is a
|
|
75
|
+
backward-incompatible reimplementation. See
|
|
76
|
+
[Migrating from 0.5.0](CHANGELOG.md#migrating-from-050).
|
|
77
|
+
|
|
43
78
|
## Quick start
|
|
44
79
|
|
|
45
80
|
```python
|
|
@@ -93,8 +128,76 @@ with SimpleQueue("./data", lease_seconds=30, max_retries=3) as queue:
|
|
|
93
128
|
```
|
|
94
129
|
|
|
95
130
|
For long-running handlers, `heartbeat_interval` renews the lease in the
|
|
96
|
-
background.
|
|
97
|
-
|
|
131
|
+
background. It must be shorter than `lease_seconds`; one-third of the lease is
|
|
132
|
+
recommended. A handler can also renew it explicitly with
|
|
133
|
+
`job.extend_lease(seconds)`, using a positive duration.
|
|
134
|
+
|
|
135
|
+
## Event bus
|
|
136
|
+
|
|
137
|
+
Optional pub/sub on top of the same durable queues (requires the `bus` extra):
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uv add "localqueue[bus]>=1.1.0"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
> [!NOTE]
|
|
144
|
+
> The event bus API requires `localqueue` 1.1.0 or newer. If the PyPI badge
|
|
145
|
+
> still shows 1.0.1, the 1.1.0 release rollout has not completed yet.
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
# shared.py
|
|
149
|
+
from localqueue.bus import BaseEvent, BusTopology
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class UserCreated(BaseEvent):
|
|
153
|
+
event_name = "user.created"
|
|
154
|
+
|
|
155
|
+
user_id: str
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
TOPOLOGY = BusTopology({"email": [UserCreated]})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
# producer.py
|
|
163
|
+
from localqueue.bus import EventBus
|
|
164
|
+
|
|
165
|
+
from shared import TOPOLOGY, UserCreated
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
bus = EventBus("./data", name="app", topology=TOPOLOGY)
|
|
169
|
+
bus.dispatch(UserCreated(user_id="123")) # atomic fan-out, committed
|
|
170
|
+
bus.close()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
# email_worker.py
|
|
175
|
+
import asyncio
|
|
176
|
+
|
|
177
|
+
from localqueue.bus import EventBus
|
|
178
|
+
|
|
179
|
+
from shared import TOPOLOGY, UserCreated
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
bus = EventBus("./data", name="app", topology=TOPOLOGY)
|
|
183
|
+
email = bus.subscription("email")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@email.handler(UserCreated)
|
|
187
|
+
async def send_welcome(event: UserCreated) -> None:
|
|
188
|
+
...
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
asyncio.run(bus.run()) # consume subscriptions handled by this process
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Each subscription is a durable queue (`__bus__:{bus}:{subscription}`), so
|
|
195
|
+
workers in multiple processes act as consumer groups. Handlers get the same
|
|
196
|
+
retry, lease, and dead-letter semantics as regular jobs. The static topology
|
|
197
|
+
decides where events are persisted; local handlers decide what the current
|
|
198
|
+
process consumes. Producers do not import handlers, and workers do not
|
|
199
|
+
participate in dispatch. See
|
|
200
|
+
[docs/event-bus.md](https://github.com/brunoportis/localqueue/blob/main/docs/event-bus.md).
|
|
98
201
|
|
|
99
202
|
## Delivery guarantees
|
|
100
203
|
|
|
@@ -158,12 +261,13 @@ queue = SimpleQueue(
|
|
|
158
261
|
| Method | Purpose |
|
|
159
262
|
| --- | --- |
|
|
160
263
|
| `put(data, job_id=None)` | Enqueue a payload, with optional deduplication. |
|
|
264
|
+
| `put_many(items)` | Atomically enqueue multiple payloads, optionally using `EnqueueItem` for per-item deduplication. |
|
|
161
265
|
| `get(block=True, timeout=None)` | Claim a job and start its lease. |
|
|
162
266
|
| `get_nowait()` | Claim immediately or raise `Empty`. |
|
|
163
267
|
| `ack(job)` | Confirm successful processing. |
|
|
164
|
-
| `nack(job, delay=0, last_error=None)` | Return a transient failure to the queue, optionally with a delay. |
|
|
268
|
+
| `nack(job, delay=0, last_error=None)` | Return a transient failure to the queue, optionally with a non-negative delay. |
|
|
165
269
|
| `fail(job, last_error=None)` | Move a permanent failure to the dead-letter state. |
|
|
166
|
-
| `extend_lease(job, seconds)` | Renew the current delivery lease. |
|
|
270
|
+
| `extend_lease(job, seconds)` | Renew the current delivery lease by a positive duration. |
|
|
167
271
|
| `reclaim_expired_leases()` | Reclaim expired leases explicitly; `get()` also does this automatically. |
|
|
168
272
|
| `stats()` | Return `ready`, `processing`, `acked`, and `failed` counts. |
|
|
169
273
|
| `list_failed(limit=100, offset=0)` | Inspect dead-letter jobs. |
|
|
@@ -218,3 +322,8 @@ Build a release wheel:
|
|
|
218
322
|
```bash
|
|
219
323
|
uv run maturin build --release --locked
|
|
220
324
|
```
|
|
325
|
+
|
|
326
|
+
## License
|
|
327
|
+
|
|
328
|
+
Licensed under the [Apache License 2.0](https://github.com/brunoportis/localqueue/blob/main/LICENSE).
|
|
329
|
+
|