Skip to content

Commit

Permalink
Update GetCookieManager bug and reopen issue (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed May 25, 2018
1 parent c546957 commit c599c59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions api/RequestHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ is the URL of the top-level frame. Cookies managers can be unique
per browser or shared across multiple browsers. The global cookie
manager will be used if this method returns None.

**IMPORTANT**: In some cases the `browser` parameter can be
None, so you should handle such case.
**IMPORTANT**: In some cases this callback is not called due to a
race condition. See Issue [#429](../../../issues/429) for details.

To successfully implement separate cookie manager per browser session,
you have to set ApplicationSettings.`unique_request_context_per_browser`
Expand Down
8 changes: 4 additions & 4 deletions docs/Migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ See a complete list of flags in the description of
cef.Request.[GetFlags](../api/Request.md#getflags) method.


## v66+ RequestHandler.GetCookieManager 'browser' param may be None
## v66+ RequestHandler.GetCookieManager not getting called in some cases

In some cases in RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager)
callback, the `browser` parameter may be None due to a race condition.
See Issue [#429](../../../issues/429) for details.
In some cases the RequestHandler.[GetCookieManager](../api/RequestHandler.md#getcookiemanager)
callback is not getting called due to a race condition.
This bug is to be fixed in Issue [#429](../../../issues/429).

13 changes: 6 additions & 7 deletions src/handlers/request_handler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,13 @@ cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager(
cdef object clientCallback
cdef PyCookieManager returnValue
try:
if cefBrowser.get():
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
else:
pyBrowser = None
if not cefBrowser.get():
# Bug: In some cases due to a race condition the browser
# may be NULL. Issue #429.
return <CefRefPtr[CefCookieManager]>NULL
pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager")
pyMainUrl = CefToPyString(cefMainUrl)
if pyBrowser:
# Browser may be empty.
clientCallback = pyBrowser.GetClientCallback("GetCookieManager")
clientCallback = pyBrowser.GetClientCallback("GetCookieManager")
if clientCallback:
returnValue = clientCallback(
browser=pyBrowser,
Expand Down

0 comments on commit c599c59

Please sign in to comment.