Skip to content

Commit

Permalink
Improve fix for possible errors on shutdown (previous commit).
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed May 26, 2016
1 parent d9bbf7c commit 8d2c1e7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/cefpython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ g_debugFile = "debug.log"
g_applicationSettings = {}
g_commandLineSwitches = {}

_MessageLoopWork_wasused = False

cdef dict g_globalClientCallbacks = {}

# If ApplicationSettings.unique_request_context_per_browser is False
Expand Down Expand Up @@ -428,6 +430,10 @@ def MessageLoopWork():
# GIL must be released here otherwise we will get dead lock
# when calling from c++ to python.

if not _MessageLoopWork_wasused:
global _MessageLoopWork_wasused
_MessageLoopWork_wasused = True

with nogil:
CefDoMessageLoopWork();

Expand All @@ -448,13 +454,18 @@ def Shutdown():
g_sharedRequestContext.Assign(NULL)
Debug("Shutdown()")
with nogil:
CefShutdown()
# Temporary fix for possible errors on shutdown. See this post:
# https://magpcss.org/ceforum/viewtopic.php?p=30858#p30858
# May be fixed by host owned message loop, see Issue 1805:
# https://bitbucket.org/chromiumembedded/cef/issues/1805/
for i in range(10):
CefDoMessageLoopWork()
if _MessageLoopWork_wasused:
for i in range(10):
CefDoMessageLoopWork()
CefShutdown()
if _MessageLoopWork_wasused:
for i in range(10):
CefDoMessageLoopWork()



def SetOsModalLoop(py_bool modalLoop):
Expand Down

0 comments on commit 8d2c1e7

Please sign in to comment.