Multiprocessing problem

I try to use multiprocessing for live data transmission and it pops up some weird bug.

Here is the reference:

Here is my

import subprocess
import sys

from direct.showbase.ShowBase import ShowBase
from multiprocessing import Process,Queue,Pipe
from mp1 import f

class MyApp(ShowBase):
    def __init__(self):

        # quit when esc is pressed
        self.accept('escape', sys.exit)

        # base.disableMouse()

        self.jack = self.loader.loadModel("jack")
        self.jack.setScale(2.0, 2.0, 2.0)
        self.jack.setPos(8, 50, 0)

    def hello(self):
        parent_conn, child_conn = Pipe()
        p = Process(target=f, args=(child_conn,))
        print(parent_conn.recv())  # prints "Hello"

app = MyApp()

Here is

from multiprocessing import Process,Pipe

def f(child_conn):
    msg = "Hello"

My expectation is when I press f, it will print “Hello” in the terminal.
However, when I press f, the programs will create a new panda3D window.
How can I solve this problem? Please let me know if you have a better solution in live data transmission

Thank you for reading this post.


if __name__ == '__main__':
   app = MyApp()

Your error tells you a strange bootstrapping message and google told me this. I can’t tell you I fully understand python things but either this is run too many times or too soon xD .

By using if __name__ == '__main__': you make sure only the main thread executes the app module…

More info about bootstrapping with multiprocessing can be found here:

1 Like