I made a simple offscreen renderer with cefpython.
I used cefpython.MessageLoop()
but I would like to execute a javascript function with browser.GetFocusedFrame().ExecuteFunction
which must be called from main UI thread.
Is there a way to set a callback on cefpython's message loop?
Alternatively I could use MessageLoopWork
, but I don't know how. I tried to call it in a separate thread but it does not work:
import threading
def main_loop():
cefpython.MessageLoopWork()
threading.Timer(0.01, main_loop).start()
threading.Timer(0.01, main_loop).start()
I get the following error:
[0324/174806:ERROR_REPORT:context.cc(146)] Check failed: false. called on invalid thread