I am running Django version 4.2.4 in async mode. For one of my apps I have some code to run on ready like this:
class CoreConfig(AppConfig):
name = 'demo.core'
def ready(self):
from .utils import my_sync_func
my_sync_func()
When I run this code, I get the warning "RuntimeWarning: coroutine 'CoreConfig.ready' was never awaited"
When I use sync_to_async like this:
class CoreConfig(AppConfig):
name = 'demo.core'
async def ready(self):
from .utils import my_sync_func
await sync_to_async(my_sync_func)()
I get the warning "RuntimeWarning: coroutine 'CoreConfig.ready' was never awaited"
What is the correct way of doing this?
Thanks a lot