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

feat(python): Raise an error when users try to use Polars API in a fork()-without-execve() child #19149

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

itamarst
Copy link
Contributor

@itamarst itamarst commented Oct 8, 2024

This is an alternative implementation for #5342, which was reverted due to side-effects.

This implementation should not affect any non-Polars using code. It won't catch all cases of people using Polars in a fork()-without-execve() child, but it will catch many of them.

@ritchie46 ritchie46 changed the title Raise an error when users try to use Polars API in a fork()-without-execve() child feat(python): Raise an error when users try to use Polars API in a fork()-without-execve() child Oct 8, 2024
@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars and removed title needs formatting labels Oct 8, 2024
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.76%. Comparing base (9dada18) to head (f6b457e).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/polars/__init__.py 50.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19149      +/-   ##
==========================================
- Coverage   79.78%   79.76%   -0.03%     
==========================================
  Files        1531     1531              
  Lines      208445   208455      +10     
  Branches     2913     2916       +3     
==========================================
- Hits       166301   166264      -37     
- Misses      41593    41639      +46     
- Partials      551      552       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# fork() breaks Polars thread pool. Instead of silently hanging when users do
# this, e.g. by using multiprocessing's footgun default setting on Linux, warn
# them instead:
def __install_postfork_hook() -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Nice fix. Any idea of the startup cost of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect it's not meaningfully slower, but I'll measure it tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This appears to add 3 or 4 µs to import polars. This doesn't seem like a problem to me.

Copy link
Member

Choose a reason for hiding this comment

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

Alright. Thanks @itamarst. Nice that we can catch those deadlocks now.

@ritchie46 ritchie46 merged commit 48bc09b into pola-rs:main Oct 10, 2024
12 of 14 checks passed
nameexhaustion added a commit to nameexhaustion/polars that referenced this pull request Oct 11, 2024
… in a fork()-without-execve() child (pola-rs#19149)"

This reverts commit 48bc09b.
ritchie46 pushed a commit that referenced this pull request Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants