N
N
Nikita Presnov2021-02-18 15:36:01
Multithreading
Nikita Presnov, 2021-02-18 15:36:01

What is the correct way to write multi-threaded applications with PyQt5?

There is an application.
On PyQt5.
In it, I request data on 10 channels from a small device (and if you just ask for them in a row in a simple Python script, we will get a frequency of 4 kHz), I display it on the screen in the form of graphs using pyqtgraph.
But in an application on an average office machine, it is not possible to squeeze out more than 20 Hz due to the drawing of the graph (while everything is running in one thread).
I want at least 1 kHz.
There is only one thought for real acceleration: to make the program multi-threaded.
In a separate thread, we ask for data, and we draw as we have to, since the execution time of a piece of code with a request is limited.
Here the question arises: what and how to use multithreading: Qt-threading or can it be pythonic?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Presnov, 2021-03-01
@discipuli

"Apparently there is no real multithreading in python,
so there is only one option: optimize rendering"
As a result, I used qthread. I wrote in vs code, and the latter could neither see the 2nd thread, nor stop at the breakpoint, I'm not even sure that the 2nd thread stopped when the pause was pressed. As I understand it, vs code works through pgb, and in order to finally understand that pyqt5 has its own threads, you need to use gdb (yes, this is also possible)
One way or another, the problem was solved.

Z
ZIK1337, 2021-02-18
@ZIK1337

If the thread is working with qt widgets, then qt-shny
If not, then you can use Python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question