Skip to content

Make trio.from_thread.run() raise RunFinishedError if the system nursery is closed#1743

Merged
njsmith merged 2 commits intopython-trio:masterfrom
oremanj:from-thread-run-lastminute
Oct 14, 2020
Merged

Make trio.from_thread.run() raise RunFinishedError if the system nursery is closed#1743
njsmith merged 2 commits intopython-trio:masterfrom
oremanj:from-thread-run-lastminute

Conversation

@oremanj
Copy link
Copy Markdown
Member

@oremanj oremanj commented Oct 1, 2020

Fixes #1738. Also improve the documentation for spawn_system_task() to more clearly indicate this possibility.

Rationale for RunFinishedError: callers to from_thread.run() already need to be able to handle the case where the run is finished, and it's difficult to distinguish "has started async generator finalization" from the case where the run is fully done. I would also entertain other options (raise Cancelled? block until the run actually finishes and then raise RunFinishedError?) if anyone wants to make a case for why a different choice might be more robust.

@oremanj oremanj requested review from RazerM and njsmith October 1, 2020 06:11
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 1, 2020

Codecov Report

Merging #1743 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1743   +/-   ##
=======================================
  Coverage   99.63%   99.64%           
=======================================
  Files         114      114           
  Lines       14427    14446   +19     
  Branches     1104     1104           
=======================================
+ Hits        14375    14394   +19     
  Misses         37       37           
  Partials       15       15           
Impacted Files Coverage Δ
trio/_core/_run.py 100.00% <ø> (ø)
trio/_threads.py 100.00% <100.00%> (ø)
trio/tests/test_threads.py 100.00% <100.00%> (ø)

Comment thread trio/_threads.py
Comment on lines +1 to +2
# coding: utf-8

Copy link
Copy Markdown
Member

@belm0 belm0 Oct 11, 2020

Choose a reason for hiding this comment

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

these headers should not be needed, right?

in the few files where this appears, git blame is always referencing your PR's. Over-eager editor setting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@belm0 Not needed indeed, feel free to remove those lines

@njsmith njsmith merged commit 32302eb into python-trio:master Oct 14, 2020
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.

TrioInternalError in trio 0.17 with sqlalchemy_aio

4 participants