Back

Can python runtime be made asynchronous in appwrite function

  • 0
  • Self Hosted
anonvt
12 Aug, 2024, 13:32

I have a python runtime function that is making API calls to 3-4 external services, and the slowest of them can take about 15 seconds to respond.

This function can be called through the frontend quite often (I can have hundreds of simultaneous calls)

To simulate, I added a simple time.sleep(15) to a test function, and called this function execution x num of times in parallel.

Looks like the function cannot handle more than 4 (amount of cores in my instance) requests. i.e. at a time only 4 requests can be executed, which means the cores are tied up when this call is made, which is expected.

However, apparently I can't use await asyncio.sleep because python worker definition is not async.

This is quite different from node runtime. I added a sleep function there, and due to the nature of node event loop, it allowed me to execute 100 functions at once.

Looking for suggestions on how to improve this number in python runtime.

TL;DR
Developers are experiencing limitations with Python runtime making asynchronous API calls due to the lack of async support. They are looking for suggestions to improve the number of simultaneous function executions beyond the core count.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more