Skip to content

PYTHON-5406 - AsyncPeriodicExecutor must reset CSOT contextvars befor… #2360

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

Merged
merged 5 commits into from
Jun 6, 2025

Conversation

NoahStapp
Copy link
Contributor

@NoahStapp NoahStapp commented Jun 5, 2025

…e executing

TODO: add tests to confirm that unwanted ContextVar state is not carried over to AsyncPeriodicExecutor tasks.

@NoahStapp NoahStapp requested a review from ShaneHarvey June 5, 2025 17:22
@@ -43,6 +43,7 @@ def cancelling(self) -> int:
return self._cancel_requests


# We can directly pass an empty Context() object to create_task in Python >= 3.11
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we'd want to do that. The user might be have contextvars that they want to propagate to the background tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A better idea I had was to explicitly remove our CSOT contextvars and leave the rest alone.

Copy link
Member

Choose a reason for hiding this comment

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

Then, should we remove this comment?

@NoahStapp NoahStapp requested a review from ShaneHarvey June 5, 2025 20:04
@NoahStapp
Copy link
Contributor Author

Test failures are unrelated, known flakey tests on PyPy.

@NoahStapp NoahStapp merged commit 536b1cb into mongodb:master Jun 6, 2025
74 of 78 checks passed
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.

2 participants