1

During the application flow I would like to close cefpython running client and open a new one; I've this function

....
while True:
    settings = {...}
    settings2= {...}
    cef.Initialize(settings=settings)
    self.BROWSER = cef.CreateBrowserSync(url=url,
                                         window_title="Tutorial", 
                                         browserSettings=settings2)

    bindings = cef.JavascriptBindings(bindToFrames=False,
                                      bindToPopups=False)
    bindings.SetFunction("backend", func)
    self.BROWSER.SetJavascriptBindings(bindings)


    cef.MessageLoop()
    cef.Shutdown()

and in another function I have this call

self.BROWSER.CloseBrowser(True)

Browser start on first run and is closed but it does not restart. If I comment the line

...
cef.MessageLoop()
#cef.Shutdown()

in the first function the browser does restart but it get stuck and I can't use it. Thanks in advance.

user1683737
  • 51
  • 1
  • 1
  • 5

1 Answers1

0

Functions like cef.Initialize and cef.Shutdown can be called only once during app lifetime. You also shouldn't call cef.MessageLoop multiple times. Your code while True doesn't make much sense, because you do not give browsers time to initialize and load. You should use events like LoadHandler.OnLoadEnd or OnLoadingStateChange or others depending on what you're trying to accomplish.

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56