Peter Wang
Peter Wang

Reputation: 1838

Multithreading Issues

This is more of a hypothetical question; I'm having some issues with a program and I'm wondering if it might be because of multithreading.

I have a main thread and a worker thread. The worker thread communicates with a machine through a serial port, and when it receives output from the machine, it emits a Pyqt signal. There is a slot in the main thread which receives the signal, and processes that output. The processing is a lengthy process which includes creating another object from the output.

If the worker thread were to call the main thread two times before the first output has finished getting processed, what would happen?

Upvotes: 0

Views: 68

Answers (1)

jweyrich
jweyrich

Reputation: 32240

While your main thread is executing a long task (originated from an event), it will not process any new events. All new events will be queued in a thread-specific queue, and will be processed later when the event loop is executed. If the targeted thread is sleeping, the new event will be queued, and the thread will be awaken to process it.

You can read the documentation on The Event System.

Upvotes: 1

Related Questions