Skip to content

Commit a5d97f0

Browse files
committed
Add GIL section to Contributing-code.md document (cztomczak#102).
1 parent 2c3681f commit a5d97f0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/Contributing-code.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Table of contents:
1212
* [API docs](#api-docs)
1313
* [Unit tests](#unit-tests)
1414
* [Platforms](#platforms)
15+
* [GIL](#gil)
1516
* [Authors](#authors)
1617
* [Updating CEF version](#updating-cef-version)
1718

@@ -123,6 +124,24 @@ In most cases new code should run fine on all platforms, but in
123124
some cases it might be required to test on all platforms before
124125
PR is merged.
125126

127+
## GIL
128+
129+
In the pxd file, functions should be defined as "nogil" to avoid
130+
deadlocks when calling CEF functions. In the pyx file the call must
131+
use the "with nogil" statement.
132+
133+
From [Cython's documentation](http://docs.cython.org/src/userguide/external_C_code.html#acquiring-and-releasing-the-gil):
134+
135+
> Note that acquiring the GIL is a blocking thread-synchronising operation,
136+
> and therefore potentially costly. It might not be worth releasing the GIL
137+
> for minor calculations. Usually, I/O operations and substantial computations
138+
> in parallel code will benefit from it.
139+
140+
Revision [ec1ce78](https://github.com/cztomczak/cefpython/commit/ec1ce788373bb9e0fd2cedd71e900c3877e9185a) removes the GIL lock from the
141+
following calls: Initialize(), Shutdown(), CreateBrowserSync(),
142+
SetOsModalLoop(), QuitMessageLoop(), CefExecuteProcess(). There still
143+
might be some more functions from which the GIL lock should be removed.
144+
126145
## Authors
127146

128147
In your pull request modify also the [Authors](../Authors) file

0 commit comments

Comments
 (0)