CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
test_module.py56 linesDownload Raw Back to test
1import sys2 3import joblib4from joblib.test.common import with_multiprocessing5from joblib.testing import check_subprocess_call6 7 8def test_version():9    assert hasattr(joblib, "__version__"), (10        "There are no __version__ argument on the joblib module"11    )12 13 14@with_multiprocessing15def test_no_start_method_side_effect_on_import():16    # check that importing joblib does not implicitly set the global17    # start_method for multiprocessing.18    code = """if True:19        import joblib20        import multiprocessing as mp21        # The following line would raise RuntimeError if the22        # start_method is already set.23        mp.set_start_method("loky")24    """25    check_subprocess_call([sys.executable, "-c", code])26 27 28@with_multiprocessing29def test_no_semaphore_tracker_on_import():30    # check that importing joblib does not implicitly spawn a resource tracker31    # or a semaphore tracker32    code = """if True:33        import joblib34        from multiprocessing import semaphore_tracker35        # The following line would raise RuntimeError if the36        # start_method is already set.37        msg = "multiprocessing.semaphore_tracker has been spawned on import"38        assert semaphore_tracker._semaphore_tracker._fd is None, msg"""39    if sys.version_info >= (3, 8):40        # semaphore_tracker was renamed in Python 3.8:41        code = code.replace("semaphore_tracker", "resource_tracker")42    check_subprocess_call([sys.executable, "-c", code])43 44 45@with_multiprocessing46def test_no_resource_tracker_on_import():47    code = """if True:48        import joblib49        from joblib.externals.loky.backend import resource_tracker50        # The following line would raise RuntimeError if the51        # start_method is already set.52        msg = "loky.resource_tracker has been spawned on import"53        assert resource_tracker._resource_tracker._fd is None, msg54    """55    check_subprocess_call([sys.executable, "-c", code])56