From 6914a2ebead02b8c7fcd634239c9ad0348738809 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 28 Apr 2021 13:02:25 -0700 Subject: [PATCH 1/2] Add `COMPILED` global variable to scheduler This should make it easy to tell whether the scheduler was compiled with Cython or not. --- distributed/scheduler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/distributed/scheduler.py b/distributed/scheduler.py index 283b430c2d..479e00388e 100644 --- a/distributed/scheduler.py +++ b/distributed/scheduler.py @@ -185,6 +185,10 @@ def nogil(func): set, {"released", "waiting", "no-worker", "processing", "erred", "memory"} ) globals()["ALL_TASK_STATES"] = ALL_TASK_STATES +COMPILED = declare( + bint, compiled +) +globals()["COMPILED"] = COMPILED @final From cb0176b2a55cbf08f3454ae317087cda9edc5ab5 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Wed, 28 Apr 2021 13:05:53 -0700 Subject: [PATCH 2/2] Simplify Cythonized Scheduler check --- distributed/tests/test_scheduler.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/distributed/tests/test_scheduler.py b/distributed/tests/test_scheduler.py index 33aab92b63..b6c9af1dc1 100644 --- a/distributed/tests/test_scheduler.py +++ b/distributed/tests/test_scheduler.py @@ -28,7 +28,7 @@ from distributed.core import ConnectionPool, Status, connect, rpc from distributed.metrics import time from distributed.protocol.pickle import dumps -from distributed.scheduler import MemoryState, Scheduler +from distributed.scheduler import COMPILED, MemoryState, Scheduler from distributed.utils import TimeoutError, tmpfile, typename from distributed.utils_test import ( # noqa: F401 captured_logger, @@ -72,14 +72,7 @@ def test_cythonized(): # cythonized as expected import distributed.scheduler - if strtobool(os.environ["CYTHONIZED"]): - expected_suffix = ".pyd" if WINDOWS else ".so" - else: - expected_suffix = ".py" - - assert distributed.scheduler.__file__.endswith( - expected_suffix - ), distributed.scheduler + assert strtobool(os.environ["CYTHONIZED"]) == COMPILED @gen_cluster()