Multiprocessing: main programm stops until process is finished
<p>I know, a minimal working example is the gold standard and I am working on it. However, maybe there is an obvious error. The function <code>run_worker</code> is executed upon a button press event. It initiates a class instance and should start a method of that class. However the function run_worker waits until the class method has finished. As a result kivy gets stuck and I cannot do other stuff. Any ideas how I should use multiprocessing in this case ?</p>

<pre><code>from multiprocessing import Process

class SettingsApp(App):
    """ Short not working version of the actual programm
    """
    def build(self):
        """Some kivy specific settings"""
        return Interface

"""This part does not work as expected. It is run by pushing a button.  However, The function does hang until the Process has finished (or has been killed)."""

    def run_worker(self):
        """The pHBot application is started as a second process. Otherwise kivy would be blocked until the function stops
        (which is controlled by the close button)
        """
        # get the arguments in appropriate form
        args = self.get_stored_settings()

        # Initiate the class which should be run by a separate process
        bot = pHBot(*args)

        # the control method runs some devices, listens to sensors etc.
        phbot = Process(target=bot.ph_control(), args=(bot,))

        # start the process
        phbot.start()

        # This statement is executed only after phbot has stopped.
        print('Started')
</code></pre>

<p>I found a solution. Not sure why it works:</p>

<pre><code>    def worker(self):
        """
        The pHBot application is started as a second process. Otherwise kivy would be blocked until the function stops
        (which is controlled by the close button)
        """
        # initiate the process
        args = self.get_stored_settings()
        bot = pHBot(*args)
        bot.ph_control()

    def run_worker(self):
        """The function is called upon button press
        """
        # start the process, is 
        self.phbot.start()
        pass # not sure if that is necessary
</code></pre>

python kivy python-multiprocessing