Compare commits

..

No commits in common. "5201b18caed0584d289798b9194e69903a912042" and "27be5d43a2807869daa45ee62154e3d2bd7f3a02" have entirely different histories.

View File

@ -1860,14 +1860,9 @@ async def test_session_registry_latency_does_not_block_the_event_loop(access_con
async def test_sign_in_throttle_lookup_does_not_block_the_event_loop(
access_control, monkeypatch
):
lookup_started = threading.Event()
lookup_finished = threading.Event()
class SlowAttempts:
def retry_after(self, source):
lookup_started.set()
time.sleep(0.3)
lookup_finished.set()
time.sleep(0.15)
return 17
def record_blocked(self, *, method):
@ -1879,13 +1874,15 @@ async def test_sign_in_throttle_lookup_does_not_block_the_event_loop(
sign_in = asyncio.create_task(
client.post("/api/v1/session", json={"access_token": "wrong"})
)
assert await asyncio.to_thread(lookup_started.wait, 1)
await asyncio.sleep(0)
started = time.perf_counter()
await asyncio.sleep(0.01)
assert not lookup_finished.is_set()
heartbeat_elapsed = time.perf_counter() - started
response = await sign_in
assert response.status_code == 429
assert response.headers["retry-after"] == "17"
assert heartbeat_elapsed < 0.08
@pytest.mark.anyio