abysshub 0.1.2.dev6__tar.gz → 0.1.2.dev8__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.
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/PKG-INFO +1 -1
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/pyproject.toml +1 -1
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_async_client.py +6 -1
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_client.py +6 -1
- abysshub-0.1.2.dev8/tests/conftest.py +18 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_client.py +5 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/.gitignore +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/LICENSE +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/README.md +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/__init__.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_error.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_files.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_http.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_run.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/_types.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/src/abysshub/py.typed +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/caller.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/fake_server.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_files.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_http.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_package.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_replay.py +0 -0
- {abysshub-0.1.2.dev6 → abysshub-0.1.2.dev8}/tests/test_timeout.py +0 -0
|
@@ -177,7 +177,7 @@ class AsyncAbyss(_Base[AsyncRun]):
|
|
|
177
177
|
async def _sleep(self, call: _Call, seconds: float) -> None:
|
|
178
178
|
"""Waits ``seconds``, or raises ``timeout`` at the call's deadline."""
|
|
179
179
|
pause, stops = self._pause(call, seconds)
|
|
180
|
-
await
|
|
180
|
+
await _wait(pause)
|
|
181
181
|
if stops:
|
|
182
182
|
raise self._timed_out(call)
|
|
183
183
|
|
|
@@ -302,3 +302,8 @@ class AsyncAbyss(_Base[AsyncRun]):
|
|
|
302
302
|
pause = reply
|
|
303
303
|
await self._sleep(call, pause)
|
|
304
304
|
attempt += 1
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
async def _wait(seconds: float) -> None:
|
|
308
|
+
"""Waits out a pause between two tries. Only the tests replace it, so as not to sleep through the real pauses."""
|
|
309
|
+
await asyncio.sleep(seconds)
|
|
@@ -409,7 +409,7 @@ class Abyss(_Base[Run]):
|
|
|
409
409
|
def _sleep(self, call: _Call, seconds: float) -> None:
|
|
410
410
|
"""Waits ``seconds``, or raises ``timeout`` at the call's deadline."""
|
|
411
411
|
pause, stops = self._pause(call, seconds)
|
|
412
|
-
|
|
412
|
+
_wait(pause)
|
|
413
413
|
if stops:
|
|
414
414
|
raise self._timed_out(call)
|
|
415
415
|
|
|
@@ -542,6 +542,11 @@ class Abyss(_Base[Run]):
|
|
|
542
542
|
attempt += 1
|
|
543
543
|
|
|
544
544
|
|
|
545
|
+
def _wait(seconds: float) -> None:
|
|
546
|
+
"""Waits out a pause between two tries. Only the tests replace it, so as not to sleep through the real pauses."""
|
|
547
|
+
time.sleep(seconds)
|
|
548
|
+
|
|
549
|
+
|
|
545
550
|
def _heard(call: _Call, headers: httpx.Headers) -> None:
|
|
546
551
|
"""Notes a response's headers as they arrive: its ``Request-Id``, and the run its ``Location`` names."""
|
|
547
552
|
call.request_id = headers.get("request-id", call.request_id)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from abysshub import _async_client, _client
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture(autouse=True)
|
|
11
|
+
def no_real_pauses(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
12
|
+
"""Makes every pause the library waits between two tries near zero, so no test sleeps through a real one."""
|
|
13
|
+
|
|
14
|
+
async def wait(seconds: float) -> None:
|
|
15
|
+
await asyncio.sleep(0)
|
|
16
|
+
|
|
17
|
+
monkeypatch.setattr(_client, "_wait", lambda seconds: None)
|
|
18
|
+
monkeypatch.setattr(_async_client, "_wait", wait)
|
|
@@ -7,6 +7,7 @@ import pytest
|
|
|
7
7
|
from fake_server import Replay, load_exchanges
|
|
8
8
|
|
|
9
9
|
from abysshub import Abyss, AbyssError, AsyncAbyss
|
|
10
|
+
from abysshub._client import REATTACH_PAUSE, RETRY_PAUSE, RETRY_PAUSE_CEILING
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
@pytest.fixture(autouse=True)
|
|
@@ -40,6 +41,10 @@ def test_no_key_raises_abyss_error() -> None:
|
|
|
40
41
|
assert raised.value.code == "invalid_api_key"
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
def test_the_pauses_are_1_s_between_reattaches_and_0_5_s_doubling_up_to_10_s_before_a_retry() -> None:
|
|
45
|
+
assert (REATTACH_PAUSE, RETRY_PAUSE, RETRY_PAUSE_CEILING) == (1.0, 0.5, 10.0)
|
|
46
|
+
|
|
47
|
+
|
|
43
48
|
def test_async_abyss_takes_the_same_options(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
44
49
|
monkeypatch.setenv("ABYSS_API_KEY", "abyss_sk_dev_x")
|
|
45
50
|
abyss = AsyncAbyss(max_retries=0, timeout=5)
|
|
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
|