Open ironhacker opened 1 year ago
Check the examples
https://github.com/sanic-org/sanic/blob/main/examples/run_async.py
You can disable uvloop either by config, or at install time with env variables.
https://sanic.dev/en/guide/deployment/configuration.html#builtin-values
I want to +1 this issue; will gladly see an example with several asyncio
servers within the same process; within my server, which runs HTTP server (sanic) and also listens to some MQ, I get this after upgrading to the latest version at the time of writing:
[2024-06-19 18:10:29 +0000] [9] [INFO] mode: production, single worker
[2024-06-19 18:10:29 +0000] [9] [INFO] server: sanic, HTTP/1.1 [2024-06-19 18:10:29 +0000] [9] [INFO] python: 3.8.19
[2024-06-19 18:10:29 +0000] [9] [INFO] platform: Linux-5.15.0-1017-gcp-x86_64-with-glibc2.34
[2024-06-19 18:10:29 +0000] [9] [INFO] packages: sanic-routing==23.12.0
[2024-06-19 18:10:32 +0000] [9] [ERROR] protocol.connection_task uncaught
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sanic/server/protocols/http_protocol.py", line 150, in connection_task
await self.app.dispatch(
File "/usr/local/lib/python3.8/site-packages/sanic/signals.py", line 304, in dispatch
return await dispatch
File "/usr/local/lib/python3.8/site-packages/sanic/signals.py", line 216, in _dispatch
group, handlers, params = self.get(event, condition=condition)
File "/usr/local/lib/python3.8/site-packages/sanic/signals.py", line 177, in get
group, param_basket = self.find_route(
TypeError: 'NoneType' object is not callable
Task exception was never retrieved
future: <Task finished name='Task-19' coro=<HttpProtocol.connection_task() done, defined at /usr/local/lib/python3.8/site-packa
ges/sanic/server/protocols/http_protocol.py:141> exception=TypeError("'NoneType' object is not callable")>
Describe the bug Every version after 21.6.2 fails when running app with app.create_server. The error is
I realize this isn't the recommended way to run Sanic, but the web server is only part of my application, does not run on startup or continuously, and shares memory with other async code. This has worked very well for me so far.
Side node: I noticed while troubleshooting that the event loop is changed to uvloop just by importing sanic. I'm of the opinion that imports shouldn't "do things". Would it be better to set the event loop when the application starts?
Code snippet
Expected behavior successful http response
Environment (please complete the following information):
Additional context Interesting bit in the status line:
[2022-08-19 12:15:06 -0400] - (sanic.access)[INFO][UNKNOWN]: NONE http:///* 503 666