Kill A Multiprocessing Pool With Sigkill Instead Of Sigterm (i Think)
So, I have this program that utilizes multiprocessing with multiple selenium browser windows. Here's what the program looks like: pool = Pool(5) results = pool.map_async(worker,ran
Solution 1:
multiprocessing.Pool
store worker processes list in Pool._pool
attr, send a signal to them is straightforward then:
import multiprocessing
import os
import signal
def kill(pool):
# stop repopulating new child
pool._state = multiprocessing.pool.TERMINATE
pool._worker_handler._state = multiprocessing.pool.TERMINATE
for p in pool._pool:
os.kill(p.pid, signal.SIGKILL)
# .is_alive() will reap dead process
while any(p.is_alive() for p in pool._pool):
pass
pool.terminate()
Post a Comment for "Kill A Multiprocessing Pool With Sigkill Instead Of Sigterm (i Think)"