+ 2

What are async functions?

I have searched it on google. But I didnt understood much. Posting here cause I need "simple words" explaination.

26th Nov 2020, 7:17 PM
HET SHAH
HET SHAH - avatar
8 Antworten
+ 6
[Part 1 of 2] HET SHAH Expanding further on Steven M's explanation, let's consider a function that uploads a file to a remote server. upload(filepath) Let's say that file is rather large and might take a minute to upload. If your program does nothing else, then it might not matter. The function is called and will complete in 1 minute. Now consider the following code with a list of 5 large files: for file in filepaths: upload(file) This is equivalent to: upload(fileList[0]) upload(fileList[1]) upload(fileList[2]) upload(fileList[3]) upload(fileList[4]) Here, the 2nd function is called after the 1st function completes. The 3rd function starts after the 2nd completes... and so on and so forth. If each call takes 1 minute, then it will take 5 minutes to complete all 5 uploads. This is known a serial (or synchronous) processing.
27th Nov 2020, 12:16 AM
David Carroll
David Carroll - avatar
+ 5
"Fire and forget"... async doesn't wait for confirmation of request delivery. Sync waits for a response and it does not perform another operation until a proper response is given; this makes it a blocking call. https://medium.com/work-insight/fire-and-forget-c611053245f8
26th Nov 2020, 7:50 PM
Steven M
Steven M - avatar
+ 5
[Part 2 of 2] With async, the 1st function is called and immediately exits before the upload is completed. The upload will just occur in the background without blocking the execution of the next code. Then, the 2nd function will be called and do the same where it exits before its upload is completed. All 5 functions might be called before the first upload is completed. This is what is meant by "fire and forget". The function fired (or was called) and then "forgotten" as in... it doesn't wait for completion to move on. This is also known as parallel or concurrent or asynchronous processing. Essentially, all 5 uploads are occurring simultaneously allowing for the process to complete quicker than one-by-one serial processing. Here's a more indepth article that might help you understand this further: https://realpython.com/async-io-JUMP_LINK__&&__python__&&__JUMP_LINK/
27th Nov 2020, 12:19 AM
David Carroll
David Carroll - avatar
+ 3
Async means that it must be repeated or looped as long as It means that it will never stop running
26th Nov 2020, 7:26 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
+ 1
26th Nov 2020, 7:55 PM
HET SHAH
HET SHAH - avatar
+ 1
David Carroll Thanks a lot! Gotcha!👍😄
27th Nov 2020, 5:18 AM
HET SHAH
HET SHAH - avatar
+ 1
Steven M 🥇👩‍💻 Kintu Michael Evans 🔥🔥 Thank you for your assistance!🙌
27th Nov 2020, 5:21 AM
HET SHAH
HET SHAH - avatar
0
Async functions its functions which parallel executed
28th Nov 2020, 2:30 PM
Arman