python-daemon interaction with multiprocessing (secure-smtpd)

Ben Finney ben at benfinney.id.au
Wed May 7 15:01:56 EDT 2014


Grant Edwards <invalid at invalid.invalid> writes:

> On 2014-05-07, Grant Edwards <invalid at invalid.invalid> wrote:
> >     How do you terminate a Python program that's using multiprocessing?
>
> It looks like you have to kill all the threads individually.  :/

As I understand it, the ‘multiprocessing’ module
<URL:https://docs.python.org/3/library/multiprocessing.html> does not
create multiple threads; it creates multiple processes.

It also closely follows the API for the ‘threading’ module. That
includes the ability to manage a pool of workers
<URL:https://docs.python.org/3/library/multiprocessing.html#module-multiprocessing.pool>.

You can ask the pool of workers to close when they're done
<URL:https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.close>.
Does that address the requirement?

-- 
 \         “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\    Brain, but if we give peas a chance, won't the lima beans feel |
_o__)                                left out?” —_Pinky and The Brain_ |
Ben Finney




More information about the Python-list mailing list