Skip to content

Commit e01a530

Browse files
committed
Use longer delay in CI to make race harder to hit
1 parent 64bcc80 commit e01a530

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/units/utils/test_tasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import asyncio
22
import contextlib
3+
import os
34
from unittest.mock import Mock
45

56
import pytest
67

78
from reflex.utils.tasks import ensure_task
89

10+
CI = bool(os.environ.get("CI", False))
11+
912

1013
class NotSuppressedError(Exception):
1114
"""An exception that should not be suppressed."""
@@ -72,13 +75,13 @@ async def faulty_coro(): # noqa: RUF029
7275

7376

7477
async def test_ensure_task_limit_window_passed():
75-
"""Test that ensure_task raises after exceeding exception limit within the limit window."""
78+
"""Test that ensure_task resets exception limit past the limit window."""
7679
call_count = 0
7780

7881
async def faulty_coro():
7982
nonlocal call_count
8083
call_count += 1
81-
await asyncio.sleep(0.05)
84+
await asyncio.sleep(0.5 if CI else 0.05)
8285
if call_count > 3:
8386
raise RuntimeError("Test Passed") # noqa: EM101
8487
raise ValueError("Should have been suppressed") # noqa: EM101
@@ -91,7 +94,7 @@ async def faulty_coro():
9194
suppress_exceptions=[ValueError],
9295
exception_delay=0,
9396
exception_limit=2,
94-
exception_limit_window=0.05,
97+
exception_limit_window=0.1 if CI else 0.01,
9598
)
9699

97100
with contextlib.suppress(asyncio.CancelledError), pytest.raises(RuntimeError):

0 commit comments

Comments
 (0)