Killing A Multiprocess Pool Using A Tkinter Button
Solution 1:
From the Pool.map
documentation:
It blocks until the result is ready.
That means that, yes, the work is being done on other threads, but the main thread (the one calling map
) will not execute anything else until the other threads are complete. You want to use map_async
and (for a long-running, interactive process), provide a callback for what to do when the pool is finished (probably hide the pop-up).
If you want your program to simply show the pop-up then exit, you want to use the AsyncResult
returned by map_async
. Set up an idle handler using after_idle
(See tkinter universal widget methods and remember you'll need to manually re-add the handler after every call). After each idle call, you could call either AsyncResult.ready()
or AsyncResult.get(<timeout>)
to see if the pool has completed. Once it's finished, you're safe to process the results and exit.
Post a Comment for "Killing A Multiprocess Pool Using A Tkinter Button"