-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
tweaks to new REPL #3002
tweaks to new REPL #3002
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3002 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 120 120
Lines 17783 17865 +82
Branches 3197 3212 +15
=======================================
+ Hits 17718 17800 +82
Misses 46 46
Partials 19 19
|
Looks like that traceback cleanup trick only works on 3.11 later. Either we could find a different trick or only assert it on recent python versions! |
Cc @clint-lawrence cause you made the original PR |
Out of date branch so updated |
The difference in editing exceptions that showed up in 3.11 is documented so I think we can just rely on it. |
And to follow up on people interested in a nursery for background tasks, my test accidentally shows that you can just use the system nursery. trio/src/trio/_tests/test_repl.py Lines 106 to 117 in 8a0b573
|
A really clean (IMO) implementation breaks certain features of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only thing I can think of is that comment after isinstance(result.error, SystemExit):
is a bit interesting:
So we print the exception and stay in the repl
Not immediately obvious that raising the error in that branch causes error to be only printed and not close repl if I am reading the comment right.
Yes, I think I did a poor job of splitting up that comment. I'm going clarify that a bit and then someone can do a nice squash merge for us. |
A follow up to #2972. These would have been review comments earlier if I knew the code was going to be (a) this simple and (b) in my wheelhouse!
I think
runcode
can just be:It's less code, less layers of onion unwrapping, and the more common
from_thread.run_sync
is more efficient (not that anyone would notice latency from two extra checkpoints at the REPL). That's the first commit.I also noticed one fragility, which is that KI works thanks to the thread task reentry feature combined with the fact that we inject
KeyboardInterrupt
into the main task. If we were to go the route of #733 (comment) and just cancel everything and transmute toKeyboardInterrupt
when the run finishes, the run would be cancelled. I put a test for this in the second commit.Finally, we can hide the threading code frames from the traceback, although I'm not sure about editing the global exception state like that. that's the last commit.