vercel-queue 0.9.1__tar.gz → 0.10.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.
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/.gitignore +3 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/PKG-INFO +2 -2
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/devserver.py +21 -1
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/embedded.py +16 -2
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/lease.py +24 -6
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/testing/pytest.py +1 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/version.py +1 -1
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/LICENSE +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/README.md +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/_vercel_hatch_build.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/hatch_build.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/pyproject.toml +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/__init__.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/__main__.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/__init__.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/api_async.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/api_common.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/api_sync.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/asynctools.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/cli.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/client.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/client_sync.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/config.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/constants.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/errors.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/http.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/log.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/messages.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/multipart.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/names.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/polling.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/push.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/response.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/retry.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/streams.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/subscribers.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/transports.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/_internal/types.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/devserver.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/embedded.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/py.typed +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/sync.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/testing/__init__.py +0 -0
- {vercel_queue-0.9.1 → vercel_queue-0.10.0}/vercel/queue/testing/state.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: vercel-queue
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: Vercel Queue client for Python
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -10,7 +10,7 @@ Requires-Dist: httpx2[http2]>=2
|
|
|
10
10
|
Requires-Dist: python-multipart>=0.0.20
|
|
11
11
|
Requires-Dist: typing-extensions>=4.0.0
|
|
12
12
|
Requires-Dist: vercel-headers>=0.7.2
|
|
13
|
-
Requires-Dist: vercel-internal-core<0.3.0,>=0.2.
|
|
13
|
+
Requires-Dist: vercel-internal-core<0.3.0,>=0.2.2
|
|
14
14
|
Requires-Dist: vercel-oidc>=0.10.0
|
|
15
15
|
Provides-Extra: devserver
|
|
16
16
|
Requires-Dist: uvicorn; extra == 'devserver'
|
|
@@ -45,7 +45,7 @@ def embedded_queue_dev_server(
|
|
|
45
45
|
timeout_graceful_shutdown=_GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS,
|
|
46
46
|
)
|
|
47
47
|
server = _cancellable_server(uvicorn, config)
|
|
48
|
-
thread =
|
|
48
|
+
thread = _ServerThread(target=_profiled_server_run(server, profile), daemon=True)
|
|
49
49
|
thread.start()
|
|
50
50
|
_wait_for_server(server)
|
|
51
51
|
base_url = f"http://{host}:{_server_port(server)}"
|
|
@@ -55,6 +55,7 @@ def embedded_queue_dev_server(
|
|
|
55
55
|
base_url=base_url,
|
|
56
56
|
app=app,
|
|
57
57
|
_thread=thread,
|
|
58
|
+
_is_serving=lambda: _is_serving(server),
|
|
58
59
|
)
|
|
59
60
|
finally:
|
|
60
61
|
try:
|
|
@@ -102,6 +103,25 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
102
103
|
return 0
|
|
103
104
|
|
|
104
105
|
|
|
106
|
+
class _ServerThread(threading.Thread):
|
|
107
|
+
"""Server thread that remembers what ended it."""
|
|
108
|
+
|
|
109
|
+
error: BaseException | None = None
|
|
110
|
+
|
|
111
|
+
def run(self) -> None:
|
|
112
|
+
try:
|
|
113
|
+
super().run()
|
|
114
|
+
except BaseException as exc:
|
|
115
|
+
self.error = exc
|
|
116
|
+
raise
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _is_serving(server: Any) -> bool:
|
|
120
|
+
return not server.should_exit and all(
|
|
121
|
+
asyncio_server.is_serving() for asyncio_server in server.servers
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
105
125
|
def _uvicorn() -> Any:
|
|
106
126
|
try:
|
|
107
127
|
return importlib.import_module("uvicorn")
|
|
@@ -1457,10 +1457,24 @@ class EmbeddedQueueDevServer:
|
|
|
1457
1457
|
base_url: str
|
|
1458
1458
|
app: EmbeddedQueueAsgiApp
|
|
1459
1459
|
_thread: threading.Thread | None = field(default=None, repr=False, compare=False)
|
|
1460
|
+
_is_serving: Callable[[], bool] | None = field(default=None, repr=False, compare=False)
|
|
1460
1461
|
|
|
1461
1462
|
def is_running(self) -> bool:
|
|
1462
|
-
"""Return whether the embedded HTTP server
|
|
1463
|
-
|
|
1463
|
+
"""Return whether the embedded HTTP server is still accepting connections."""
|
|
1464
|
+
if self._thread is not None and not self._thread.is_alive():
|
|
1465
|
+
return False
|
|
1466
|
+
return self._is_serving is None or self._is_serving()
|
|
1467
|
+
|
|
1468
|
+
def ensure_running(self) -> None:
|
|
1469
|
+
"""Raise if the embedded HTTP server has stopped, chaining why it stopped.
|
|
1470
|
+
|
|
1471
|
+
A server that dies mid-session otherwise surfaces only as connection
|
|
1472
|
+
errors in whichever tests run next, with the cause long gone.
|
|
1473
|
+
"""
|
|
1474
|
+
if self.is_running():
|
|
1475
|
+
return
|
|
1476
|
+
error = getattr(self._thread, "error", None)
|
|
1477
|
+
raise RuntimeError("embedded queue dev server stopped unexpectedly") from error
|
|
1464
1478
|
|
|
1465
1479
|
def reset(self) -> None:
|
|
1466
1480
|
"""Reset server state and cached clients between tests."""
|
|
@@ -10,16 +10,20 @@ but it does not wait for the first lease extension to complete. This surfaces
|
|
|
10
10
|
delivery failures at handler startup without coupling startup to renewal
|
|
11
11
|
network I/O. Fire-and-forget stop paths are still logged asynchronously.
|
|
12
12
|
|
|
13
|
-
Stopping a renewal removes future work and cancels any
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
Stopping a renewal removes future work. A fire-and-forget stop also cancels any
|
|
14
|
+
in-flight extension, because acknowledge paths can avoid that tail latency:
|
|
15
|
+
late renewals are harmless after ACK. A waited stop instead lets an in-flight
|
|
16
|
+
extension finish, up to the stop timeout. Cancelling a request client-side
|
|
17
|
+
cannot retract it once it has reached the service, so only completion
|
|
18
|
+
guarantees that a late automatic renewal cannot overwrite the visibility
|
|
19
|
+
update the RetryAfter path applies next.
|
|
17
20
|
|
|
18
21
|
Lease renewal invariants:
|
|
19
22
|
|
|
20
23
|
- A renewal handle is single-use and idempotently stoppable.
|
|
21
24
|
- Start waits for worker scheduling, not lease extension I/O.
|
|
22
|
-
- Stop with wait=True waits for in-flight renewal
|
|
25
|
+
- Stop with wait=True waits for an in-flight renewal to complete, cancelling it
|
|
26
|
+
only once the stop timeout has passed.
|
|
23
27
|
- At most one renewal for a token may be in flight at a time.
|
|
24
28
|
- Command submission uses a large bounded AnyIO memory stream.
|
|
25
29
|
"""
|
|
@@ -150,6 +154,7 @@ class _LeaseRenewalTask:
|
|
|
150
154
|
request: _LeaseExtensionRequest
|
|
151
155
|
cancel_scope: anyio.CancelScope
|
|
152
156
|
stop_waiters: list[_LeaseExtensionStop]
|
|
157
|
+
extension_in_flight: bool = False
|
|
153
158
|
|
|
154
159
|
|
|
155
160
|
@dataclass(kw_only=True)
|
|
@@ -788,6 +793,15 @@ async def _handle_lease_extension_stop(
|
|
|
788
793
|
if renewal_task is not None:
|
|
789
794
|
if command.done_send is not None or command.done_event is not None:
|
|
790
795
|
renewal_task.stop_waiters.append(command)
|
|
796
|
+
if renewal_task.extension_in_flight:
|
|
797
|
+
# The caller is about to change visibility itself. Cancelling
|
|
798
|
+
# the request cannot retract it once the service has it, so
|
|
799
|
+
# let it land first, but no longer than the caller waits.
|
|
800
|
+
renewal_task.cancel_scope.deadline = min(
|
|
801
|
+
renewal_task.cancel_scope.deadline,
|
|
802
|
+
anyio.current_time() + _LEASE_STOP_WAIT_TIMEOUT_SECONDS,
|
|
803
|
+
)
|
|
804
|
+
return
|
|
791
805
|
renewal_task.cancel_scope.cancel()
|
|
792
806
|
return
|
|
793
807
|
|
|
@@ -871,7 +885,11 @@ async def _run_lease_renewal_task(
|
|
|
871
885
|
await anyio.sleep(max(0.0, request.next_extension_at - time.monotonic()))
|
|
872
886
|
if state.active.get(request.token) is not renewal_task:
|
|
873
887
|
return
|
|
874
|
-
|
|
888
|
+
renewal_task.extension_in_flight = True
|
|
889
|
+
try:
|
|
890
|
+
await _run_lease_extension(request, _LeaseTaskActiveMap(state.active))
|
|
891
|
+
finally:
|
|
892
|
+
renewal_task.extension_in_flight = False
|
|
875
893
|
finally:
|
|
876
894
|
with anyio.CancelScope(shield=True):
|
|
877
895
|
if state.active.get(request.token) is renewal_task:
|
|
@@ -21,6 +21,7 @@ def embedded_queue_server(
|
|
|
21
21
|
_embedded_queue_server_session: EmbeddedQueueDevServer,
|
|
22
22
|
) -> Iterator[EmbeddedQueueDevServer]:
|
|
23
23
|
"""Return an isolated embedded queue server state for a test."""
|
|
24
|
+
_embedded_queue_server_session.ensure_running()
|
|
24
25
|
_embedded_queue_server_session.reset()
|
|
25
26
|
try:
|
|
26
27
|
yield _embedded_queue_server_session
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|