django-unicorn icon indicating copy to clipboard operation
django-unicorn copied to clipboard

Investigate using async view for message endpoint

Open adamghill opened this issue 4 years ago • 4 comments

Once Django 3.1 and async views are available, see how hard it would be to use an async view if configured.

adamghill avatar Aug 04 '20 00:08 adamghill

@adamghill Do you have any news about using async views with Unicorn ?

gschurck avatar Mar 22 '23 17:03 gschurck

is there any update to using async? Especially using it in the actions. I tried it and it's throwing an error as you might already know. I am using 0.52.0

hyusetiawan avatar Aug 06 '23 17:08 hyusetiawan

I haven't looked into async other than the initial commit above to set up a way to prototype it. Can you create a PR with an initial use case? That would give me a good starting place.

adamghill avatar Aug 06 '23 22:08 adamghill

it's pretty straight forward to set up actually. Just have an async action like so:

from asyncio import sleep
async def submit_form(self):
    sleep(3)
    self.text = 'done'

right now, we can actually make it work by decorating it using async_to_sync decorator

hyusetiawan avatar Aug 06 '23 22:08 hyusetiawan