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

Use forkserver start method for multiprocessing #296

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion green/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,15 @@ def main(argv: Sequence[str] | None = None, testing: bool = False) -> int:
temp_dir_for_tests = tempfile.mkdtemp()
atexit.register(lambda: shutil.rmtree(temp_dir_for_tests, ignore_errors=True))
os.environ["TMPDIR"] = temp_dir_for_tests
prev_tempdir = tempfile.tempdir
tempfile.tempdir = temp_dir_for_tests
return _main(argv, testing)
try:
return _main(argv, testing)
finally:
del os.environ["TMPDIR"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we would want reset TMPDIR to the previous version if any. Since it was the pre-existing behavior I'm approving since the changes are definitely a net improvement.

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We checked that TMPDIR was not set before entering this if branch. (Technically, it was either unset or set to an empty string, but these are the same for python's tempfile logic, so I think it's fine to delete in either case.)

tempfile.tempdir = prev_tempdir
else:
return _main(argv, testing)


if __name__ == "__main__": # pragma: no cover
Expand Down