How to keep track of thread progress in Python without freezing the PyQt GUI?

后端 未结 5 1242
余生分开走
余生分开走 2020-12-12 20:07

Questions:

  1. What is the best practice for keeping track of a tread\'s progress without locking the GUI (\"Not Responding\")?
  2. Gene
5条回答
  •  臣服心动
    2020-12-12 20:19

    You are always going to have this problem in Python. Google GIL "global interpretor lock" for more background. There are two generally recommended ways to get around the problem that you are experiencing: use Twisted, or use a module similar to the multiprocessing module introduced in 2.5.

    Twisted will require that you learn asynchronous programming techniques which may be confusing in the beginning but will be helpful if you ever need to write high throughput network apps and will be more beneficial to you in the long run.

    The multiprocessing module will fork a new process and uses IPC to make it behave as if you had true threading. Only downside is that you would need python 2.5 installed which is fairly new and inst' included in most Linux distros or OSX by default.

提交回复
热议问题