Skip to content

Commit 4300c10

Browse files
committed
warn about the profiler when used in tests
1 parent d6160c8 commit 4300c10

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

distributed/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import inspect
55
import logging
6+
import os
67
import sys
78
import threading
89
import traceback
@@ -356,6 +357,15 @@ def __init__(
356357

357358
if not hasattr(self.io_loop, "profile"):
358359
if dask.config.get("distributed.worker.profile.enabled"):
360+
current_test = os.environ.get("PYTEST_CURRENT_TEST")
361+
if current_test and "_profile" not in current_test:
362+
warnings.warn(
363+
f"The profiler was enabled in {current_test}."
364+
" running the profiler in tests is not recommended.",
365+
RuntimeWarning,
366+
stacklevel=2,
367+
)
368+
359369
ref = weakref.ref(self.io_loop)
360370

361371
def stop() -> bool:

0 commit comments

Comments
 (0)