4

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

I'm using PyQt4,So I thought about using QThread but it seems difficult to deal with, so I wondered if it was the best way before really trying to understand it.

My Question is: is QThread the best way or there are other ways?‬

4
  • 1
    I'm not really into QT. But can't you just do it with QTimer? Dec 30, 2011 at 17:37
  • i'm afraid form QTimer may it harm the performance .
    – eyadof
    Dec 30, 2011 at 17:40
  • I suppose it would if you have a huge db... Dec 30, 2011 at 17:42
  • by 'performance of my program' you mean responsive gui?
    – warvariuc
    Dec 31, 2011 at 9:16

1 Answer 1

1

According to the fact that python implementation rely on the GIL, even with using threads or timer you won't be able to do something (potentially costly) in your program without effecting the global performance of the program.

I will suggest you to have a look to multiprocessing module to get around of this limitation. Using this module, you will no more use threads (that are affected by the GIL), but processes (not affected by GIL).

Maybe you could create a subprocess that will arm a timer to make the update every 500ms when the main process will continue his job.

Then, you will let the system do the job of balancing the programs and it may be better in term of responsiveness (especially in a multi core environment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.