Thanks sir, I have been checking about this asynchronous way of programming for some days now but couldn't understand, i have reffered many videos from youtube but none of them is clearly explaining your video really helped me in understanding. Your content's really good wishing you all success.
That's an insane speed boost. Thanks a lot for these tutorials. They are very helpful. and completely out of the box, perf_counter() was an unexpected bonus, that I'll be using from here on out. Keep up the good work.
Why is the write_file function async? It looks like the content of the function are synchronous unless I'm not understanding something? Would it make a difference if it was just: def write_file(n, content): #
correct, write_file will always execute in a synchronous manner , but declaring it a as coroutine ,it can be used in await statemens so that the awaiting function always waits for the file to be written before proceeding further. In terms of speed it is as you say . the speed improvement here comes from the fact that aiohttp is built to handle requests asynchronously . Awaiting to get an async http aiohttp response works faster because the call yield to another request that s ready to go
Thanks sir, I have been checking about this asynchronous way of programming for some days now but couldn't understand, i have reffered many videos from youtube but none of them is clearly explaining your video really helped me in understanding. Your content's really good wishing you all success.
Write file is locking operation. You should use async library for that.
This video was super helpful and helped save my project a lot of time in development!! Thank you :)
Why not using Aiofile to have the write function async ?
That's an insane speed boost. Thanks a lot for these tutorials. They are very helpful. and completely out of the box, perf_counter() was an unexpected bonus, that I'll be using from here on out. Keep up the good work.
I love this channel and like the good community around here and Python
Why is the write_file function async? It looks like the content of the function are synchronous unless I'm not understanding something?
Would it make a difference if it was just:
def write_file(n, content): #
correct, write_file will always execute in a synchronous manner , but declaring it a as coroutine ,it can be used in await statemens so that the awaiting function always waits for the file to be written before proceeding further. In terms of speed it is as you say . the speed improvement here comes from the fact that aiohttp is built to handle requests asynchronously . Awaiting to get an async http aiohttp response works faster because the call yield to another request that s ready to go
The write file function must be execute using: loop.run_in_executor since write in a file is not handled by the io multiplexer
Constructing an aiohttp.Clientsession on each call is very expensive.
So... LN28 is the Promise.all counterpart of JavaScript.