How to run different child process independently in python?
I have various python function which i intend to run independently. For exmaple , def graphic() is responsible for all GUI elements and renders GUI def connect() this function constantly listens and connects to other system
The problem is these 2 functions are not running in parallel. I have used multiprocessing module in python This is a gist of the code
p = Process ( target = graphic() , args = () )
p1 = Process (target = connect() , args = () )
p.start()
p1.start()
p.join()
p1.join()
These 2 functions eventhough are run in different process are not running in parallel. I am only able to connect to systems if i close the GUI. Is there any way i can spawn process parallely, where i c开发者_运维百科an run graphic and connect functions independently ?
Possibly because you're calling the functions instead of passing a reference to them? ie, the first two lines should be:
p = Process(target=graphic, args=())
p1 = Process(target=connect, args=())
精彩评论