django / channels

Developer-friendly asynchrony for Django
https://channels.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.01k stars 793 forks source link

django.core.exceptions.SynchronousOnlyOperation #2106

Closed shashwat-trendmicro closed 2 weeks ago

shashwat-trendmicro commented 2 weeks ago

Hey There, I'm facing a weird issue when working with the following Configuration, I have recently added django channels for updating changes concurrently in our application,

Packages that I we have used are : django-cacheops==6.2 Python 3.7.17 django==3.0.3

I have tried updating these packages : django==3.2+ redis==4.0+ django-cacheops==7.0.2

Error that I'm facing is :

django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async. 2024-06-18 05:53:46 [ERROR ] (log.log_response) Internal Server Error: /api/settings/categories/ Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.7/contextlib.py", line 73, in inner with self._recreate_cm(): File "/usr/local/lib/python3.7/site-packages/cacheops/transaction.py", line 70, in enter self._no_monkey.enter(self) File "/usr/local/lib/python3.7/site-packages/django/db/transaction.py", line 175, in enter if not connection.get_autocommit(): File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 390, in get_autocommit self.ensure_connection() File "/usr/local/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner raise SynchronousOnlyOperation(message)

Can any body help me with this issue?