1

I'm trying to use QProcess to run a class method in a separate process. I know that the following code won't work but I am wondering if there is a tweak for starting a new process by QProcess rather than using multiprocessing.process(target=function_name)

import multiprocessing
from PyQt5 import QtCore

class myClass:
    def __init__(self):
        self.x = 20

    def loop(self,):
        for i in range(1,1000):
            self.x = i

M = MyClass()

# p = multiprocessing.process(target=MyClass.loop) # Is QProcess capable of doing this?
p = QtCore.QProcess(myClass.loop) # I know this won't work but I am looking for a way to use QProcess for ths purpose
p.start()

1 Answer 1

1

I recommend you to open a QThread and put all your variables into the thread class, in the thread class do the QProcess, and here is an example from my project: https://www.github.com/min20120907/Cell_RCNN_Qt/tree/master/Cell_Trainer.py

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.