How to solve uvloop not working in pypy

I want to speed up python, so I choose pypy. But when running Sanic, it prompts that uvloop is not installed. When I check the pip list, I find that uvloop has been installed successfully, which is very strange.

env is below

pypy:pypy3.9-v7.3.10-linux64
platform: Linux-5.4.0-135-generic-x86_64-with-glibc2.29

pip list in pypy

Package            Version
------------------ ---------------------
aiofiles           22.1.0
anyio              3.6.2
certifi            2022.12.7
cffi               1.15.1
charset-normalizer 2.1.1
greenlet           0.4.13
h11                0.14.0
hpy                0.0.4.dev179+g9b5d200
httpcore           0.16.2
httptools          0.5.0
httpx              0.23.1
idna               3.4
multidict          6.0.3
pip                22.3.1
PyMySQL            1.0.2
readline           6.2.4.1
requests           2.28.1
rfc3986            1.5.0
sanic              22.9.1
sanic-routing      22.8.0
setuptools         58.1.0
sniffio            1.3.0
urllib3            1.26.13
uvloop             0.17.0
websockets         10.4

while run with pypy

[2022-12-12 13:31:09 +0000] [9449] [INFO]
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                             Sanic v22.9.1                              β”‚
  β”‚                    Goin' Fast @ http://0.0.0.0:8000                    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚                       β”‚     mode: production, single worker            β”‚
  β”‚     β–„β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ     β”‚   server: sanic, HTTP/1.1                      β”‚
  β”‚    β–ˆβ–ˆ                 β”‚   python: 3.9.15                               β”‚
  β”‚     β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–„     β”‚ platform: Linux-5.4.0-135-generic-x86_64-with- β”‚
  β”‚                 β–ˆβ–ˆ    β”‚           glibc2.31                            β”‚
  β”‚    β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€     β”‚ packages: sanic-routing==22.8.0                β”‚
  β”‚                       β”‚                                                β”‚
  β”‚ Build Fast. Run Fast. β”‚                                                β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

[2022-12-12 13:31:09 +0000] [9449] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
[2022-12-12 13:31:09 +0000] [9449] [WARNING] You are trying to use uvloop, but uvloop is not installed in your system. In order to use uvloop you must first install it. Otherwise, you can disable uvloop completely by setting the 'USE_UVLOOP' configuration value to false. Sanic will now continue to run with the default event loop.
[2022-12-12 13:31:09 +0000] [9463] [WARNING] You are trying to use uvloop, but uvloop is not installed in your system. In order to use uvloop you must first install it. Otherwise, you can disable uvloop completely by setting the 'USE_UVLOOP' configuration value to false. Sanic will now continue to run with the default event loop.
[2022-12-12 13:31:10 +0000] [9463] [INFO] Starting worker [9463]

running with python don’t have this problem

[2022-12-12 13:32:54 +0800] [10328] [INFO]
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                             Sanic v22.9.1                              β”‚
  β”‚                    Goin' Fast @ http://0.0.0.0:8000                    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚                       β”‚     mode: production, single worker            β”‚
  β”‚     β–„β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ     β”‚   server: sanic, HTTP/1.1                      β”‚
  β”‚    β–ˆβ–ˆ                 β”‚   python: 3.8.10                               β”‚
  β”‚     β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–„     β”‚ platform: Linux-5.4.0-135-generic-x86_64-with- β”‚
  β”‚                 β–ˆβ–ˆ    β”‚           glibc2.29                            β”‚
  β”‚    β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€     β”‚ packages: sanic-routing==22.8.0                β”‚
  β”‚                       β”‚                                                β”‚
  β”‚ Build Fast. Run Fast. β”‚                                                β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

[2022-12-12 13:32:54 +0800] [10328] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
[2022-12-12 13:32:54 +0800] [10336] [INFO] Starting worker [10336]

So I wondered . Is Sanic suitable for pypy? .and with no uvloop wiil the Sanic run slowly?

as up to 2023 ,Is Sanic still the most fastest python web framwork yet ?

looking forward to your replying. Thanks

It has been a while since we put a serious effort into pypy compatibility. TBH, I am not sure what its current state is since there generally has been little interest in it. On cPython without uvloop, there is a big difference in performance. In pypy? You would have to test that yourself.

ok,I got it.
I also interested in the Sanic Speed. Is Sanic still the most fastest python web framwork yet ?
see these benchmarks:TechEmpower Framework Benchmarks
and is there any advice in developing python web application with Sanic.

and is there any advice in developing python web application with Sanic.

Self-plug here… If you are interested, I wrote a book on that exact question: https://sanicbook.com/

what about the speed of Sanic between other python web framwork?

I do not comment on that question. Benchmarking is way too subjective, and there are already attempts out there (your link being one of them) that try to answer this already.

1 Like

got it Thank you very much.