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

[Bug] Make _self_call_placeholder_ thread-safe #1034

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hudson-ai
Copy link
Collaborator

@hudson-ai hudson-ai commented Sep 18, 2024

Puts _self_call_placeholder_ in threading.local() to prevent other threads from tricking the decorator into thinking we're in a recursive call.

Small note: the thread-local storage is in the wrapped function's closure, not an attribute on the function itself.

Tests would be nice, but annoyingly I can only stochastically reproduce the issue as it is due to a race condition. Increasing the number of threads and/or jobs might make the bug occur with higher probability though -- happy to add @mmoskal's repro if we're all okay with a slightly stochastic test...

Closes #1031

@hudson-ai
Copy link
Collaborator Author

Ping @mmoskal (for some reason, I can't mark you as a reviewer... not in the org?)

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.47%. Comparing base (edd8b87) to head (e406a70).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1034      +/-   ##
==========================================
- Coverage   70.16%   61.47%   -8.69%     
==========================================
  Files          62       62              
  Lines        4471     4473       +2     
==========================================
- Hits         3137     2750     -387     
- Misses       1334     1723     +389     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

attribute caching not thread-safe
2 participants