[PyQt] Is QThread a (multi)process or a thread?
phil at riverbankcomputing.com
Mon Nov 21 21:21:33 GMT 2016
On 21 Nov 2016, at 8:58 pm, Sampsa Riikonen <sampsa.riikonen at iki.fi> wrote:
> I am launching two subclassed QThreads. In order to share information between the two QThreads I do the following:
> QThread (1) sends a signal that is connected to a slot of QThread (2)
> That signal [QtCore.pyqtSignal(object)] sends a python object having an attribute/"sub"-object that is a numpy array occupying a few megabytes of data, i.e.:
> It works correctly and smoothly .. but I am baffled of what actually happens here..
> 1) If QThread is some sort of subclass of multiprocessing.Process, then it should use semaphores and shared memory for these things
> 2) If QThread is a python thread, then I should be able to see the same variables between QThread 1 and 2 but that does not seem to be the case
> 3) Are they threads executed by the main qt process..? Then, how does the sharing of the object and the underlying numpy array work..?
> What is going on under the hood?
A QThread is a native thread. Each thread can run Python code but (because of the GIL) only one thread can be running Python code at any one time.
More information about the PyQt