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
[Trio] Quick fixes to make Sanic usable on hypercorn -k trio myweb.app #1767
Conversation
We're going to need to update the CI tests for this, but I like where it's going. Could you add a quick section in docs/sanic/examples.rst for it? |
sanic/response.py
Outdated
@@ -3,7 +3,8 @@ | |||
from os import path | |||
from urllib.parse import quote_plus | |||
|
|||
from aiofiles import open as open_async # type: ignore | |||
#from aiofiles import open as open_async # type: ignore | |||
from trio import open_file as open_async |
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.
The easy way'd be defining those incompatible imports in compat.py
module, then import things from compat.
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.
Somewhat better now but detection of environment by argv is far from optimal...
Codecov Report
@@ Coverage Diff @@
## master #1767 +/- ##
==========================================
- Coverage 92.18% 92.03% -0.16%
==========================================
Files 22 23 +1
Lines 2240 2273 +33
Branches 419 424 +5
==========================================
+ Hits 2065 2092 +27
- Misses 136 141 +5
- Partials 39 40 +1
Continue to review full report at Codecov.
|
@Tronic linter is complaining but everything else looks good now |
LGTM. |
Okay. FWIW, this is a bit hacky and probably not 100 % functional/problem-free in Trio mode yet. |
We'll just note in the docs that it's 'experimental support' |
Quite surprisingly it only took a few lines of changes to make Sanic run on Trio (with Trio-using webapp), on top of Hypercorn. If it is that easy, I'd like to include this in mainline, provided that it can be configured in some smart way (the first commit lacks configuration).
Is there some way that the library could be chosen at module load time, to avoid importing aiofiles when running on trio?