appwrite / playground-for-python

Simple examples that help you get started with Appwrite + Python (=❤️)
https://appwrite.io
MIT License
63 stars 51 forks source link

Asynchronous Python Playground #22

Closed Nibba2018 closed 2 years ago

Nibba2018 commented 3 years ago

Hi @eldadfux , I tried a workaround to run python playground asynchronously. Do have a look. This PR refers to this issue

API Calls

eldadfux commented 3 years ago

@Nibba2018 do you think this PR will make a better default example than the synced version?

Nibba2018 commented 3 years ago

@eldadfux , I did some tests and found that this takes the same amount of time to execute compared to the synced version. So I am still a bit doubtful whether this is truly asynchronous. I think we have to implement __await__() for sdk classes to get better results. I am currently creating a detailed issue on sdk-generator.

Niraj-Kamdar commented 3 years ago

This won't work because there isn't any awaitable coroutine in your asynchronous functions. This will just run synchronously and will take more time then synchronous counterpart due to the additional overhead of the event loop. You have two options to make it asynchronous either by running it in another thread by using run_in_executor or make the underlying library asynchronous. The first one is easy.

Nibba2018 commented 3 years ago

@Niraj-Kamdar , Okay let me try this.