Multiprocessing and Indigo
Posted: Mon Mar 27, 2017 7:59 pm
I'm starting to experiment with multiprocessing in one of my plugins, but I'm getting results I don't understand. If I try to run a separate process in an embedded or linked script, I don't seem to get any results. However, while it *appears* that I'm able to start a separate process within my own plugin, I can't seem to figure out a way to successfully name the process or successfully pass any arguments to the method being called by the process. A simple example:
The above seems to run successfully when I invoke it within my plugin, but when I try to access the args that I passed, I get the NoneType default and I don't get the process name 'Foo' but rather the name 'MainProcess'.
Can someone smarter than me please provide an example of how to get a separate process to run within a plugin? I clearly have more to figure out.
- Code: Select all
import multiprocessing
def method_name(self, arg=None):
indigo.server.log(str(arg))
indigo.server.log(multiprocessing.current_process().name)
p1 = multiprocessing.Process(name='Foo', target=self.method_name(), args=(arg_to_pass,))
p1.start()
p1.join()
The above seems to run successfully when I invoke it within my plugin, but when I try to access the args that I passed, I get the NoneType default and I don't get the process name 'Foo' but rather the name 'MainProcess'.
Can someone smarter than me please provide an example of how to get a separate process to run within a plugin? I clearly have more to figure out.