import concurrent.futures
import time
start = time.perf_counter()
def do_something(seconds):
print(f'Sleeping {seconds} second(s)...')
time.sleep(seconds)
return f'Done Sleeping...{seconds}'
with concurrent.futures.ThreadPoolExecutor() as executor:
secs = [5, 4, 3, 2, 1]
results = executor.map(do_something, secs)
# for result in results:
# print(result)
# threads = []
# for _ in range(10):
# t = threading.Thread(target=do_something, args=[1.5])
# t.start()
# threads.append(t)
# for thread in threads:
# thread.join()
finish = time.perf_counter()
print(f'Finished in {round(finish-start, 2)} second(s)')
Subscribe to:
Post Comments (Atom)
Git
1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...
-
https://github.com/crossplane-contrib
-
awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \ <(grep 'cpu ...
-
output = 'curl http://<jenkinsUserName>:<jenkinsPassword>@<jenkinsIP>:<jenkinsPort>/job/<J...
No comments:
Post a Comment