I'm making a class that subclasses multiprocessing.Process
.
When doing some testing,
I noticed that the process was not starting when start()
was called.
After some testing, it appears that the processes do not start until 2 lines of code are executed in the __main__
module.
As an example
import multiprocessing
class Test(multiprocessing.Process):
def __init__(self, *args, **kwargs):
super(Test, self).__init__(*args, **kwargs)
print('created')
def run(self, *args, **kwargs):
super(Test, self).run(*args, **kwargs)
print('running')
sample = Test()
>>> created
sample.start()
pass # Did not start yet
pass # Will start after this
>>> running
I've tested this on different platforms, and it works as expected there.
I'm running Windows 10, Python 3.5.2.
Output of sys.version
is '3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]'