Change minimum Python to 3.9 and add Trio sample#162
Conversation
dandavison
left a comment
There was a problem hiding this comment.
Nice, a few comments aimed at making the comments maximally understandable.
| from trio_async import workflows | ||
|
|
||
|
|
||
| @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives |
There was a problem hiding this comment.
Could you expand this comment slightly, are we basically saying
without this decorator you wouldn't be able to use anything from the
asynciomodule.
?
There was a problem hiding this comment.
Yes, "allows asyncio primitives" was meant to imply "needed to allow asyncio primitives", otherwise if it wasn't needed we could remove the decorator. I can rephrase if needed (though don't want to effectively re-document https://trio-asyncio.readthedocs.io/en/latest/usage.html#calling-asyncio-from-trio). I admit I didn't go over all of asyncio module to confirm you can use nothing without this, so not sure the statement about "anything" is correct.
| # custom event loop. Therefore Trio primitives should never be used in a | ||
| # workflow, only asyncio helpers (which delegate to the custom loop). |
There was a problem hiding this comment.
These comments are very helpful. Two teaks: if "primitives" and "helpers" are the same thing can we use the same word, and can you give an example so that it's really clear what we can and can't do. Something like this:
| # custom event loop. Therefore Trio primitives should never be used in a | |
| # workflow, only asyncio helpers (which delegate to the custom loop). | |
| # custom event loop. Therefore Trio primitives such as XXX should never be used in a | |
| # workflow, only functions and classes from the asyncio module, (which delegate to the custom loop). |
There was a problem hiding this comment.
I intentionally did helpers here because to me primitives is helpers + event loop, and here it's just helpers. I want the user to understand that it's only the high-level helpers of asyncio used in the workflow, not asyncio itself.
| from trio_async import activities, workflows | ||
|
|
||
|
|
||
| @trio_asyncio.aio_as_trio # Note this decorator which allows asyncio primitives |
There was a problem hiding this comment.
As above, would be good to expand and clarify this. Are we saying
without this decorator you wouldn't be able to use anything from the
asynciomodule.
?
There was a problem hiding this comment.
Yes, I can adjust. I do not believe it is true that it's anything from the asyncio module because I didn't go over everything in that module. Is there another way to phrase it? Or is what's there ok?
|
Assuming the other wording is good enough, merging. Can revisit if needed. |
What was changed
Checklist