Skip to content

Commit

Permalink
warn about the profiler when used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Aug 24, 2022
1 parent 599708e commit 9244428
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion distributed/cli/tests/test_dask_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ def test_version_option():
assert result.exit_code == 0


@pytest.mark.filterwarnings(
"ignore"
":The profiler was enabled in .* running the profiler in tests is not recommended"
":RuntimeWarning"
)
@pytest.mark.slow
def test_idle_timeout():
start = time()
Expand All @@ -483,8 +488,8 @@ def test_idle_timeout():
distributed.cli.dask_scheduler.main, ["--idle-timeout", "1s"]
)
stop = time()
assert 1 < stop - start < 10
assert result.exit_code == 0
assert 1 < stop - start < 10


@pytest.mark.slow
Expand Down
10 changes: 10 additions & 0 deletions distributed/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import inspect
import logging
import os
import sys
import threading
import traceback
Expand Down Expand Up @@ -356,6 +357,15 @@ def __init__(

if not hasattr(self.io_loop, "profile"):
if dask.config.get("distributed.worker.profile.enabled"):
current_test = os.environ.get("PYTEST_CURRENT_TEST")
if current_test:
warnings.warn(
f"The profiler was enabled in {current_test}."
" running the profiler in tests is not recommended.",
RuntimeWarning,
stacklevel=2,
)

ref = weakref.ref(self.io_loop)

def stop() -> bool:
Expand Down

0 comments on commit 9244428

Please sign in to comment.