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

Wait subprocess cleanup #1010

Merged
Changes from 2 commits
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: 9 additions & 0 deletions src/rez/package_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,15 @@ def add_variants_async(self, variants):
stderr=out_target,
**kwargs
)

if (platform.system() == "Windows"
and sys.version_info < (3, 7)):
# Wait subprocess cleanup
# This is a Python<=3.6 won't fix on Windows.
# Based on issue: https://bugs.python.org/issue37380
# and the comment: https://bugs.python.org/msg346332
_.wait(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this raise a TimeoutExpired exception if the rez-pkg-cache daemon runs for longer than 1 sec? (Or am I missing something - this seems highly probable).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, somehow I got really sloppy on this one, and you are right. It raises TimeoutExpired exception when the process runs longer than 1 sec.

I have changed to use Python 3.7 and didn't revisit this PR since then.
Now that I am back and I found the reason of this issue seems to be related to garbage collect...

Changing _.wait(1) into import gc;gc.collect() solved the problem. (but we shouldn't need this...)

One additional info, I got the idea that the issue might be related to the garbage collection is from this comment, and here's the repro that's been mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, jsut do del _ before function return or not keeping the reference of the subprocess instance in variable _ solved the problem. :O


except Exception as e:
print_warning(
"Failed to start package caching daemon (command: %s): %s",
Expand Down