Guest User

Untitled

a guest
Jun 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. def myCoroutine(id):
  5. process_time = random.randint(1,5)
  6. time.sleep(process_time)
  7. print("Coroutine {}, has finished after {} seconds.".format(id, process_time))
  8.  
  9. def main():
  10. start = time.time()
  11. tasks = []
  12. for i in range(10):
  13. tasks.append(myCoroutine(i))
  14. end = time.time()
  15. print("This task took " + str(end - start) + " seconds to complete.")
  16.  
  17. main()
Add Comment
Please, Sign In to add comment