Oct-18-2021, 05:25 PM
I am just learning to work with multi threads/process.
I wrote this code and it works well:
I think the code is not working at all.
I wrote this code and it works well:
import time import concurrent.futures numThreads = 3 def do_something(sec): print('start sleeping ',sec) time.sleep(sec) print('end sleeping ', sec) sec = [5,4,3,2,1] with concurrent.futures.ThreadPoolExecutor(max_workers = numThreads) as pool: pool.map(do_something, sec,timeout = 1)when I switch from Thread to Process. Nothing is printed on the screen.
I think the code is not working at all.
import time import concurrent.futures numThreads = 3 def do_something(sec): print('start sleeping ',sec) time.sleep(sec) print('end sleeping ', sec) sec = [5,4,3,2,1] with concurrent.futures.ProcessPoolExecutor(max_workers = numThreads) as pool: pool.map(do_something, sec,timeout = 1)any reason for this?