Created
June 18, 2018 08:35
-
-
Save JeremyEnglert/d9f5e79d89aceb4102fdc7b74cfde3da to your computer and use it in GitHub Desktop.
Sync Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
def myCoroutine(id): | |
process_time = random.randint(1,5) | |
time.sleep(process_time) | |
print("Coroutine {}, has finished after {} seconds.".format(id, process_time)) | |
def main(): | |
start = time.time() | |
tasks = [] | |
for i in range(10): | |
tasks.append(myCoroutine(i)) | |
end = time.time() | |
print("This task took " + str(end - start) + " seconds to complete.") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment