Skip to content

use put_nowait for message to stop resource managers #23

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

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lymbo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ def run_test_plan(test_plan: TestPlan, max_workers: Optional[int] = None) -> int
run_tests_with_scopes_and_shared_queue, test_plan
)

for r in execresult:
pass # TODO log result
for worker_result in execresult:
logger().debug(f"run_test_plan - worker result: [{worker_result}]")

# should already be 0 but we force this value because this is what stop the resources manager processes
with scopes[LYMBO_TEST_SCOPE_GLOBAL]["lock"]:
scopes[LYMBO_TEST_SCOPE_GLOBAL]["count"] = 0

for _ in range(max_workers if max_workers else 4):
shared_queue.put({"stop": True})
shared_queue.put_nowait({"stop": True})

# Wait for a maximum of 30 seconds for all resource managers to complete
try:
for future in concurrent.futures.as_completed(
resources_manager_futures, timeout=30
):
try:
_ = future.result() # TODO log result
resource_manager_result = future.result()
logger().debug(
f"run_test_plan - resource manager result: [{resource_manager_result}]"
)
except concurrent.futures.TimeoutError:
logger().debug(
"run_test_plan - A resource manager process timed out while waiting for completion."
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down