-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Simply exit DataLoader when Python is dying #12700
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
Conversation
|
Also, the general recommendation is to never use |
| # | ||
| # 2. The iterator exits the workers when the loader process and/or worker | ||
| # processes exits unexpectedly (e.g., SIGKILL-ed). | ||
| # processes exits normally or with error. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ezyang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, love the commentary.
|
last commit is only comment change and build passed on previous commit so I'm landing. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SsnL is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
I struggled with yet another DataLoader hang for the entire evening. After numerous experiments, I realized that it is unsafe to do anything when Python is shutting down. We also unfortunately implement our DataLaoder cleaning-up logic in
__del__, a function that may or may not be called during shutdown, and if called, may or may not be called before core library resources are freed.Fortunately, we are already setting all our workers and pin_memory_thread as daemonic. So in case of Python shutting down, we can just do a no-op in
__del__and rely on the automatic termination of daemonic children.An
atexithook is used to detect Python exit.