Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyEnglert/d9f5e79d89aceb4102fdc7b74cfde3da to your computer and use it in GitHub Desktop.
Save JeremyEnglert/d9f5e79d89aceb4102fdc7b74cfde3da to your computer and use it in GitHub Desktop.
Sync Python
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