-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Halting pytest.main() when invoked via multiprocessing #7165
Comments
Hi @ptrivedi2610, When you say it doesn't work, what does it mean exactly? Nothing happens? Also, please specify the details requested in the issue template, it will help us understand the issue better. |
@bluetech Is there a way to programatically stop pytest session from ScriptP.py, such that ScriptP.py need not to be stopped ? |
One way to accomplish that is setting You can do that via the class StopPlugin:
def pytest_sessionstart(self, session):
self.session = session
def stop(self):
self.session.shouldstop = "stopped by parent process"
stop_plugin = StopPlugin()
pytest.main(argv, plugins=[stop_plugin]) Then you need to somehow make the parent process communicate with the child process and call |
@nicoddemus Thanks a lot for the quick help. Is there a way to fix this ? I need immediate halting of pytest I even tried to use self.session.Interrupted as mentioned in #3574 but didn't work |
For a direct halt, termination of the process is required |
@RonnyPfannschmidt Yes, but then when calling process.terminate(), I am loosing all the teardowns. I want a behavior similar to SIGINT Below is more info on the issue
Thus I have to manually code some workaround that would programatically halt pytest, but after passing through all teardowns |
based on your information there doesnt seem to be a way to make what you ask for work on windows |
pytest will check Unfortunately I don't think it is possible to accomplish what you want, I'm afraid. I'm closing this for now because I think we have exhausted all our options, but feel free to post further questions and we can reopen this if there are more suggestions to try out. 👍 |
@nicoddemus |
Hi,
I currently am facing issue to stop execution of pytest from below scenario
How to achieve this ?
I tried using pytest.exit() from ProcessS, sys.exit() from ProcessS etc. but does not work
The text was updated successfully, but these errors were encountered: