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

Async and parler #339

Open
MaehMaeh opened this issue May 10, 2023 · 0 comments
Open

Async and parler #339

MaehMaeh opened this issue May 10, 2023 · 0 comments

Comments

@MaehMaeh
Copy link

MaehMaeh commented May 10, 2023

Has anyone had experience with parler in an asynchronous environment?

The problem is, when I call my_model.description, I get the error: You cannot call this from an asynchronous context - use a thread or sync_to_async. Likewise, when I call await sync_to_async(my_model.description)().

What works is if I move description to its own function:

@sync_to_async
def translation_description_resolver(my_model):
    desc = my_model.description
    return desc

async def translation_resolver(my_model) -> str:
    desc = await translation_description_resolver(my_model)
    return desc

But this effort is immense. Does anyone here have a better idea?

PS Is the project still maintained? at least as I was still in a synchronous environmentIt would be a shame if not, as I have been very happy with the project so far (at least as I was still in a synchronous environment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant