I am currently using threading.Thread()
to execute python-functions which are time-consuming, and therefore should not impact my user interface. Typically, the functions to be executed are class functions, and are moved into threads in other class functions of the same class with a code similar to
self.t = threading.Thread(target = self.long_function_to_run, args=(), kwargs={})
self.t.daemon = True
self.t.start()
Now, I would like to move everything to use QThread instead, to be able to use signals and slots instead of having to rely on Queue()
-queues.
Nevertheless, to do that, I have to create my own worker-class, subclass it from either QObject
or QThread
(as described in https://stackoverflow.com/a/6789205/2546099), and then execute this class. This would add significant overhead, and therefore I was wondering if there are any alternatives similar to my initial approach, without subclassing?