Thread slows down when running cefpython MessageLoop()

Deadly 提交于 2019-12-14 02:28:41

问题


I made a simple offscreen renderer with cefpython.

I use cefpython.MessageLoop(), and I have a separate thread to do something every seconds:

[... cefpython initialization ...]

startTime = time.time()

def main_loop():
    print time.time() - startTime
    threading.Timer(1, main_loop).start()

main_loop()
cefpython.MessageLoop()

This works fine, but it slows down after 30 seconds (then the loop updates every 10 seconds).

This is the output that I get:

[CEF Python] Initialize() called
[CEF Python] CefExecuteProcess(): exitCode = -1
[CEF Python] CefInitialize()
[...]
3.11049604416
4.11594009399
5.11900210381
[...]
27.2121961117
28.2259521484
29.2369601727
[... then it updates every 10 seconds ...]
40.1490521431
50.1502101421
60.1521630287

Strangely, the loop also updates when I switch focus from my terminal window to google chrome (but not when I switch from my terminal to other apps).

--- Update ---

The loop runs properly if I give focus on the python app (accessible from python's rocket icon on the OS X dock). I was confused because the loop does not updates properly when I give focus to the terminal with which I launched the python script.

来源:https://stackoverflow.com/questions/29255630/thread-slows-down-when-running-cefpython-messageloop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!