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

Catch Py312+ warning when using ratarmount #4819

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

cphyc
Copy link
Member

@cphyc cphyc commented Feb 15, 2024

PR Summary

Since Python 3.12, os.fork() throws a deprecation warning when called from multiple threads.
This causes the tests relying on ratarmount (to mount archives) to fail. In this PR, I superficially address the issue by catching the warning on the test side.

The long-term solution would be to update ratarmount to a more recent version.

@cphyc
Copy link
Member Author

cphyc commented Feb 15, 2024

@yt-fido test this please

Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

We should probably not except the deprecation warning to pop up, as this will fail again if/when ratarmount fixes it in the future.
If the fix is just to ignore the warning for now, it should be done in conftest.py

@neutrinoceros
Copy link
Member

I think we also need to report the problem upstream and link the issue in a comment next the the warning filter

@cphyc cphyc force-pushed the fix-ratarmoung-warning-py312 branch from dea5e73 to 3524c6b Compare February 15, 2024 14:26
conftest.py Outdated
Comment on lines 190 to 191
# On Python 3.12+, there is a deprecation warning when calling os.fork()
# in a multi-threaded process
Copy link
Member

Choose a reason for hiding this comment

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

this comment should be a condition. Something like
if find_spec("ratarmount") is not None and sys.version_info >= (3, 12):

@cphyc cphyc force-pushed the fix-ratarmoung-warning-py312 branch from 3524c6b to daa6be5 Compare February 15, 2024 14:32
@cphyc
Copy link
Member Author

cphyc commented Feb 15, 2024

I have now caught the warning in the config file.

Note however that the warning is not a ratarmount issue but a yt one. It is caused by the fact that ratarmount is called in a subprocess (see comment: https://github.com/cphyc/yt/blob/3524c6b305fcd710aa0155dd30e9e4ae39085a5d/yt/loaders.py#L1792-L1795). In practice, this is only a problem if load_archive is called from a thread, which happens for pytests, but doesn't surface in most practical cases.

@neutrinoceros
Copy link
Member

Dear me. Can't wait to see how this behaves in no-gil Python. Anyway, thank you for addressing this !

@neutrinoceros neutrinoceros added this to the 4.3.1 milestone Feb 15, 2024
@neutrinoceros neutrinoceros merged commit c148f72 into yt-project:main Feb 15, 2024
12 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Feb 15, 2024
@cphyc cphyc deleted the fix-ratarmoung-warning-py312 branch February 16, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pytest tests: running tests Issues with the test setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: yt/tests/test_load_archive.py::test_load_archive is failing
2 participants