Skip to content

avoid holding a reference to exception and value in to_thread_run_sync #3229

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

graingert
Copy link
Member

No description provided.

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00000%. Comparing base (0ea9328) to head (0987dc6).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3229   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             124          124           
  Lines           18779        18837   +58     
  Branches         1269         1270    +1     
===============================================
+ Hits            18779        18837   +58     
Files with missing lines Coverage Δ
src/trio/_core/_entry_queue.py 100.00000% <100.00000%> (ø)
src/trio/_core/_tests/test_run.py 100.00000% <ø> (ø)
src/trio/_core/_tests/tutil.py 100.00000% <100.00000%> (ø)
src/trio/_tests/test_threads.py 100.00000% <100.00000%> (ø)
src/trio/_threads.py 100.00000% <100.00000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@graingert graingert force-pushed the fix-to-thread-keeping-hold-of-outcome branch from 98c1100 to fc2edc7 Compare March 21, 2025 17:29
Copy link
Contributor

@TeamSpen210 TeamSpen210 left a comment

Choose a reason for hiding this comment

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

This seems like just reimplementing outcome. If you need to copy, why not instantiate outcome.Value/Error directly? Only detail that's different is unwrap doesn't clear values, but we could just inline the implementation into the unwrap location? Or add unwrap_clear() or something.

@graingert
Copy link
Member Author

This seems like just reimplementing outcome. If you need to copy, why not instantiate outcome.Value/Error directly? Only detail that's different is unwrap doesn't clear values, but we could just inline the implementation into the unwrap location? Or add unwrap_clear() or something.

oh yeah that's the plan, I want to get a proof of concept working first

@graingert
Copy link
Member Author

@graingert graingert changed the title avoid holding a reference to Outcome in to_thread_run_sync avoid holding a reference to exception and value in to_thread_run_sync Mar 22, 2025
@graingert graingert marked this pull request as ready for review March 24, 2025 07:50
@@ -46,6 +46,7 @@ python -m uv pip install build
python -m build
wheel_package=$(ls dist/*.whl)
python -m uv pip install "trio @ $wheel_package" -c test-requirements.txt
python -m uv pip install https://github.com/python-trio/outcome/archive/e0f317813a499f1a3629b37c3b8caed72825d9c0.zip
Copy link
Member

Choose a reason for hiding this comment

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

Leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

No I've not got the change landed in Outcome

Copy link
Member

Choose a reason for hiding this comment

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

We're going to leave a pinned commit in ci.sh? This seems sketchy.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, once everything's decided on and merged in I'll update the pyproject.toml and remove this

Copy link
Contributor

Choose a reason for hiding this comment

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

If python-trio/outcome#45 (comment) is true then I'd at least like a PR that removes dependence on those, even if it doesn't come with tested guarantees. That way any sort of outcome 2.0 release isn't as annoying.

But I also see this PR doesn't change any .value or .error so I assume we already conform with clear-on-unwrap semantics?

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.

4 participants