Skip to content
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

when use "uvicorn" to start django project, will get this error "django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async." #30

Open
zhangweiqaz opened this issue May 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@zhangweiqaz
Copy link

File "/data/.../kubeconfig_management/venv/lib/python3.10/site-packages/casbin_adapter/apps.py", line 12, in ready
initialize_enforcer(db_alias)
File "/data/.../kubeconfig_management/venv/lib/python3.10/site-packages/casbin_adapter/enforcer.py", line 67, in initialize_enforcer
with connect.cursor() as cursor:
File "/data/.../kubeconfig_management/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 24, in inner
raise SynchronousOnlyOperation(message)
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

@casbin-bot
Copy link

@techoner @Nekotoxin

@casbin-bot casbin-bot added the bug Something isn't working label May 24, 2024
@hsluoyz
Copy link
Member

hsluoyz commented May 29, 2024

We need to add a "Async" version for this django-orm-adapter, repo here: https://github.com/pycasbin/async-django-orm-adapter

Refer to other Async version middlewares: https://github.com/pycasbin?q=async&type=all&language=&sort=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants