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

fork example ignores child processes exit code #120

Open
IlyaSemenov opened this issue Jan 23, 2018 · 3 comments
Open

fork example ignores child processes exit code #120

IlyaSemenov opened this issue Jan 23, 2018 · 3 comments

Comments

@IlyaSemenov
Copy link

IlyaSemenov commented Jan 23, 2018

The fork example (https://github.com/jonashaag/bjoern/blob/master/tests/fork.py) ignores child processes' exit codes. Whatever happens to the children, the parent process will exit gracefully. This does not allow to run it with supervisord or similar means (which automatically restart crashed processes).

Additionally, the fork example will allow a situation when (on a multi-CPU machine) half of child processes crashed for some reason, the other half is still alive, and the server is thus underperforming (not utilizing all CPU cores).

I personally reworked the end of the file like this:

        try:
            # Wait for the first worker to exit. They should never exit!
            # Once first is dead, kill the others and exit with error code.
            pid, xx = os.wait()
            worker_pids.remove(pid)
        finally:
            for pid in worker_pids:
                os.kill(pid, signal.SIGINT)
            exit(1)
@jonashaag
Copy link
Owner

I guess we should rather re-spawn the children?

@IlyaSemenov
Copy link
Author

That should work, too.

@jonashaag
Copy link
Owner

OK, feel free to submit a patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants