0

Iam working multiple multiprocessing pool starmap_async which was working fine, but the main issue is, how i can kill only particular pool.

tkinter UI

When i select the Camp1 and run it was running,it select list related to the campaign and running without issue.

self.pool = Pool(processes=10)
p = list(itertools.product(searchengines, selecteddomains, searchterms))
params = [(a, api, name_of_camp, da, pidfileloc, proxies,
                       logfileloc, hours, domainfileloc,
                       siteregistration, mozapi, mozsecret) for a in p]
self.pool.starmap_async(Expired_Search, params)

I cant get the Pool ID to terminate the process. Is there any way to get Pool ID to terminate the process of the campaign i selected.

Any help would be appreciated. Thanks

Naveen
  • 1
  • 2
  • What is a "pool ID"? No, there is no easy way to get the process ID of a particular subprocess working on a given job. – AKX Nov 16 '22 at 10:09
  • @AKX Generally we use ```processid = multiprocessing.current_process().pid``` to get the current process id, is there anway to parent ID, i use ```multiprocessing.parent_process().pid``` but it was giving main .exe file ID and it was closing the exe file when i terminate the parent ID – Naveen Nov 16 '22 at 10:13
  • The `Pool` lives in the parent process, it isn't a separate process. If you want to kill all pool subprocesses, `pool.terminate()` – AKX Nov 16 '22 at 10:15
  • @AKX is there any chance to get the pool spawn pid.if not, what alternative you advise for tkinter + list + multirprocessing – Naveen Nov 16 '22 at 10:20
  • @AKX please see the image link once [tkinter UI](https://i.stack.imgur.com/bvI8F.png) if i select only Camp1 and hit stop, it has to stop only Camp1 Iam trying to acheive it, if i select ```pool.terminate()``` it will terminate all running process – Naveen Nov 16 '22 at 10:22
  • If you need to be able to pinpoint the process and kill it, use a `multiprocessing.Process`, not a pool. – AKX Nov 16 '22 at 11:48

1 Answers1

0

Found solution with multiprocessing.Process. Thanks to @AKX

self.executor = Process(target=Expired_Search, args=(p, api, name_of_camp, da,
                                                             pidfileloc, proxies,  logfileloc, hours,
                                                             domainfileloc, siteregistration, mozapi, mozsecret))
self.executor.start()
Naveen
  • 1
  • 2