I am using Async function in my django program, and tested it on development laptop PC, it has no any issue. but after uploaded to my own PC server, then face: " SynchronousOnlyOperation at /convertor/ You cannot call this from an async context - use a thread or sync_to_async", I have checked django, python, and other tools’s version, they are the same with my laptop PC side, this is really strange, why it works on laptop PC, then doesn’t work on the server When I access it with a locap IP: http://12.23.282.232:8000
the interesting thing, if I started the django app on the server side locally, then if I access it via lcoahost:80001, it works, there is no " SynchronousOnlyOperation at /convertor/",
the log:
SynchronousOnlyOperation at /convertor/
You cannot call this from an async context - use a thread or sync_to_async.
Request Method: | POST |
---|---|
Request URL: | http://12.23.282.232/convertor/ |
Django Version: | 5.1.5 |
Exception Type: | SynchronousOnlyOperation |
Exception Value: | You cannot call this from an async context - use a thread or sync_to_async. |
Exception Location: | /home/xeon/.local/lib/python3.10/site-packages/django/utils/asyncio.py, line 24, in inner |
Raised during: | app.views.submit_handler |
Python Executable: | /usr/bin/python3 |
Python Version: | 3.10.12 |
Python Path: | ``` |
[‘/home/kvm/insight’, | |
‘/usr/bin’, | |
‘/usr/lib/python310.zip’, | |
‘/usr/lib/python3.10’, | |
‘/usr/lib/python3.10/lib-dynload’, | |
‘/home/xeon/.local/lib/python3.10/site-packages’, | |
‘/usr/local/lib/python3.10/dist-packages’, | |
‘/usr/lib/python3/dist-packages’, | |
‘/home/xeon/.local/lib/python3.10/site-packages/setuptools/_vendor’] |