Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optmize timing excecutor timeout test #103276

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions tests/util/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,17 @@ def _do_nothing():
async def test_overall_timeout_reached(caplog: pytest.LogCaptureFixture) -> None:
"""Test that shutdown moves on when the overall timeout is reached."""

iexecutor = InterruptibleThreadPoolExecutor()

def _loop_sleep_in_executor():
time.sleep(1)

for _ in range(6):
iexecutor.submit(_loop_sleep_in_executor)

start = time.monotonic()
with patch.object(executor, "EXECUTOR_SHUTDOWN_TIMEOUT", 0.5):
iexecutor = InterruptibleThreadPoolExecutor()
for _ in range(6):
iexecutor.submit(_loop_sleep_in_executor)
start = time.monotonic()
iexecutor.shutdown()
finish = time.monotonic()
finish = time.monotonic()

assert finish - start < 1.2
assert finish - start < 1.3

iexecutor.shutdown()