Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Every component's process is now its own process group leader #1666

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

gsalgado
Copy link
Contributor

@gsalgado gsalgado commented Apr 11, 2020

IOW, for every process we start, we create a new process group.
This way a Ctrl-C in the terminal won't cause a SIGINT to be sent
to each of our processes, instead a single one will be sent to the
parent process, which will then send SIGINTs to every child (via
asyncio-run-in-process' open_in_process()).

Turns out our integration tests rely on all processes belonging to a single process group so that they can be correctly terminated between tests, so I had to add this new env var to control whether or not to use separate process groups.

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok going forward with this but I'm curious whether it would make more sense to do this by default under the hood in asyncio_run_in_process rather than injecting it here at the application level. Since asyncio_open_in_process is designed to handle SIGINT it seems like it would make sense for it to do this by default.


async def run(self) -> None:
start_new_session = True
if os.getenv('TRINITY_SINGLE_PROCESS_GROUP') == "1":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rather than putting this logic in the run method here it could just live inside the get_subprocess_kwargs method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I'd like to think a bit more about the implications about making this behaviour the default in asyncio-run-in-process, though, so I've filed an issue for that

IOW, for every process we start, we create a new process group.
This way a Ctrl-C in the terminal won't cause a SIGINT to be sent
to each of our processes, instead a single one will be sent to the
parent process, which will then send SIGINTs to every child (via
asyncio-run-in-process' open_in_process()).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants