Skip to content
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

Behavex runner gets stuck indefinitely when a test case terminates with sys.exit/seg fault #114

Open
lazareviczoran opened this issue Oct 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@lazareviczoran
Copy link

Describe the bug
Hello, we ran into a case where we noticed that the runner gets stuck while running the test cases when one of the test processes ends unexpectedly. We tried to dig into this and figure out why this behavior is occurring, and we noticed that there is an open bug in the multiprocessing.Pool where if the function that is being executed as a subprocess ends with a sys.exit/seg fault, the process will get stuck on the join part indefinitely. Seems like the concurrent.futures.ProcessPoolExecutor has this specific issue fixed, not sure if there would be some other side effects that would break the current behavex behavior, but it might be worth looking into it.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following code snippet (with the multiprocessing.Pool) to get the current behavior (the pool getting stuck, but all 10 subprocesses will ran)
import multiprocessing
import sys

def func_that_exits():
    sys.exit(0)

process_pool = multiprocessing.Pool(3)

for i in range(10):
    process_pool.apply_async(func_that_exits, ())

process_pool.close()
print('joining')
process_pool.join()
print('joined')
  1. Run the following code snippet (with concurrent.futures.ProcessPoolExecutor) to get the behavior where the main process won't get stuck, but only 3 "subprocesses" will run
from concurrent.futures import ProcessPoolExecutor
import sys

def func_that_exits():
    sys.exit(0)

process_pool = ProcessPoolExecutor(3)

for i in range(10):
    process_pool.submit(func_that_exits)

print('joining')
process_pool.shutdown()
print('joined')

Expected behavior
In case any of the test cases exits with a seg fault or a sys.exit, the runner should exit instead of hanging indefinitely.

Desktop (please complete the following information):

  • OS: linux/macOS
  • Browser: not relevant
  • behavex version: 2.0.1
@hrcorval hrcorval added the bug Something isn't working label Nov 22, 2023
@jbridger
Copy link

jbridger commented Dec 4, 2023

Hi @hrcorval!

As this was causing us issues, we wanted to have an attempt at addressing it and providing additional debug information.

Would be great if you could have a look at our PR on this: #120

Thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants