Ensure guest run is initialized when start_guest_run() returns#2696
Ensure guest run is initialized when start_guest_run() returns#2696richardsheridan merged 4 commits intopython-trio:masterfrom
Conversation
88f604d to
db3853a
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2696 +/- ##
=======================================
Coverage 98.94% 98.94%
=======================================
Files 113 113
Lines 16851 16885 +34
Branches 3032 3036 +4
=======================================
+ Hits 16673 16707 +34
Misses 123 123
Partials 55 55
|
A5rocks
left a comment
There was a problem hiding this comment.
This looks sane and makes sense to me (though I have a couple bits I don't get, like next_send being different on Windows and non-Windows), but I really don't know how guest runs work or anything like that.
Probably wait for someone else to review!
|
|
|
Well, hopefully someone with knowledge reviews this + #2700 in the near future! (Just bumping this :P ) |
|
This PR has a typing "problem" in that it correctly sends |
Run a few ticks of the guest run synchronously within
start_guest_run, so that global Trio operations such ascurrent_time()andspawn_system_task()work as soon asstart_guest_runreturns (rather than at some indefinite point in the near future).Motivating use case: allowing trio/asyncio integration beginning from asyncio mode to start up a Trio run and create a backing Trio task for an asyncio task that's about to enter Trio mode, all from a sync-colored context. The reverse (starting an asyncio guest run synchronously) is already supported by aioguest and is necessary to support sync-colored wrappers around asyncio-flavored async functions; that idiom is less common for Trio-flavored code, but it's still convenient to be able to treat both directions of transition in the same way, and it seems likely this PR could simplify other guest-mode wrappers as well.