Locust monkey patching leads to test cross-talking
mreso opened this issue ยท 0 comments
mreso commented
๐ Describe the bug
Some fail tests fail if locust is imported in test_benchmark.py
Error logs
> self.pid = _posixsubprocess.fork_exec(
args, executable_list,
close_fds, tuple(sorted(map(int, fds_to_keep))),
cwd, env_list,
p2cread, p2cwrite, c2pread, c2pwrite,
errread, errwrite,
errpipe_read, errpipe_write,
restore_signals, start_new_session,
gid, gids, uid, umask,
preexec_fn)
E AttributeError: 'NoneType' object has no attribute 'fork_exec'
/home/ubuntu/miniconda3/envs/serve/lib/python3.10/subprocess.py:1796: AttributeError
----------------------------------------------------------------------------------------------------- Captured stdout setup -----------------------------------------------------------------------------------------------------
TorchServe is not currently running.
TorchServe is not currently running.
['torchserve', '--start', '--model-store', '/tmp/pytest-of-ubuntu/pytest-20/work_dir0/model_store', '--ts-config', '/tmp/pytest-of-ubuntu/pytest-20/tp_model0/config.properties', '--no-config-snapshots', '--disable-token', '--
model-api-enabled']
======================================================================================================= warnings summary ========================================================================================================
../miniconda3/envs/serve/lib/python3.10/site-packages/locust/__init__.py:15
/home/ubuntu/miniconda3/envs/serve/lib/python3.10/site-packages/locust/__init__.py:15: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6.
It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util.ssl_ (/home/ubuntu/m
iniconda3/envs/serve/lib/python3.10/site-packages/urllib3/util/ssl_.py)', 'urllib3.util (/home/ubuntu/miniconda3/envs/serve/lib/python3.10/site-packages/urllib3/util/__init__.py)'].
monkey.patch_all()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================================================================================== short test summary info ====================================================================================================
ERROR test/pytest/test_auto_recover.py::test_tp_inference - AttributeError: 'NoneType' object has no attribute 'fork_exec'
============================================================================================ 1 passed, 1 warning, 1 error in 12.15s =============================================================================================
Installation instructions
dev
Model Packaging
none
config.properties
none
Versions
0.11
Repro instructions
pytest test/pytest/test_benchmark.py test/pytest/test_auto_recover.py
Possible Solution
gevent/gevent#1016 or not importing locust in test