kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 59 forks source link

OSError: [WinError 87] 'pytest --tests-per-worker auto' in terminal (pycharm, windows) #102

Open jakeschuler1 opened 2 years ago

jakeschuler1 commented 2 years ago

`PS C:\Users\Jake\PycharmProjects\stress_testing_browser> pytest --tests-per-worker auto ========================================================================================================= test session starts ========================================================================================================= platform win32 -- Python 3.9.5, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 rootdir: C:\Users\Jake\PycharmProjects\stress_testing_browser plugins: forked-1.3.0, parallel-39-0.1.0, xdist-2.3.0 collected 4 items
pytest-parallel: 1 worker (process), 4 tests per worker (threads) INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages_pytest\main.py", line 269, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages_pytest\main.py", line 323, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pluggy_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pluggy_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pluggy_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "c:\users\jake\pycharmprojects\stress_testing_browser\venv\lib\site-packages\pytest_parallel__init__.py", line 313, in pytest_runtestloop INTERNALERROR> process.start() INTERNALERROR> File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start INTERNALERROR> self._popen = self._Popen(self) INTERNALERROR> File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen INTERNALERROR> return _default_context.get_context().Process._Popen(process_obj) INTERNALERROR> File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen INTERNALERROR> return Popen(process_obj) INTERNALERROR> File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in init INTERNALERROR> reduction.dump(process_obj, to_child) INTERNALERROR> File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump INTERNALERROR> ForkingPickler(file, protocol).dump(obj) INTERNALERROR> AttributeError: Can't pickle local object 'ArgumentParser.init..identity'

======================================================================================================== no tests ran in 0.09s ======================================================================================================== Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\connection.py", line 317, in _recv_bytes Traceback (most recent call last): File "", line 1, in File "C:\Users\Jake\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 102, in spawn_main source_process = _winapi.OpenProcess( OSError: [WinError 87] The parameter is incorrect `

I'm running pytest-parallel-39, wondering if this is a simply fix -I'm attempting to use pytest-parallel for its multiprocessing capabilities...If I understand correctly then this add-on will allow me to utilize all cpus to concurrently execute multiple browsers even on the same website?

Thank you for the help, I am a new programmer and this is my first time using this site.

jakeschuler1 commented 2 years ago

@r2dev2 Hi, it seems you updated the pytest-parallel-39 so I will tag you aswell.

r2dev2 commented 2 years ago

I see you seem to be using forked on windows. Windows does not have a fork() function so it will not work. Also, generally, python multiprocessing is broken on Windows and should be avoided. If you are trying to utilize all cpu cores for multiple browsers, you can create multiple selenium webdriver objects and just use the threading capabilities of this project.

If you are looking for a project which makes this capability easier, I made a library called autoparaselenium (although I am sure there are probably others that do the same job) which can help you although I have not tested it on Windows yet.