Writing data so many times in a SQLite database using python

I want to use SQLite for my GUI Python application, but I need to update the database every 500 MS without increasing the performance of my program.

I use PyQt4, so I thought about using QThread, but it's hard to handle, so I wondered if this was the best way before trying to figure it out.

My question is: is there a better way to QThread or are there other ways?

+4
source share
1 answer

As the python implementation relies on the GIL , even with threads or a timer, you cannot do anything (potentially expensive) in your program without affecting the global performance of the program.

I suggest you take a look at multiprocessing to get around this limitation. Using this module, you will no longer use threads (which are affected by GIL), but processes (which are not affected by GIL).

Perhaps you could create a subprocess that will set a timer for updates every 500 ms when the main process continues.

Then you let the system balance the programs, and that might be better in terms of responsiveness (especially in a multi-core environment).

+1
source

Source: https://habr.com/ru/post/1388638/


All Articles