Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Add Comment
Please, Sign In to add comment