Open deepak7448 opened 1 year ago
Workaround when upgrading package versions and not running async Django.
Run this code before strawberry_django_jwt is initiated. For example in the beginning of urls.py.
import strawberry_django.utils
def fix_is_async(*args, **kwargs):
return False
strawberry_django.utils.is_async = fix_is_async
Here's how I fixed it
import asyncio
def is_async() -> bool:
"""
Helper function to determine if the current context is asynchronous.
:return: True if the current asyncio event loop is running, False otherwise.
"""
try:
loop = asyncio.get_running_loop()
return loop.is_running()
except RuntimeError:
return False
return False
Currently working on a fork lib towards a stable django 4 & 5 only build, updating deps, keeping the same API surface.
In case you're trying to do the same at home,
If successful in getting something clean, will release it publicly. Lmk if interested or willing to contribute to that - setting up sth on discord ?
When I'm importing this - from strawberry_django_jwt.decorators import login_required then its gives this error ImportError: cannot import name 'is_async' from 'strawberry_django.utils'