Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
9687773f
Commit
9687773f
authored
Mar 19, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread initialisation when using with gil/nogil (by Lisandro)
parent
7424de83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+7
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+15
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
9687773f
...
...
@@ -1604,6 +1604,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env
.
generate_library_function_declarations
(
code
)
self
.
generate_filename_init_call
(
code
)
code
.
putln
(
"/*--- Threads initialization code ---*/"
)
code
.
putln
(
"#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS"
)
code
.
putln
(
"#ifdef WITH_THREAD"
)
code
.
putln
(
"PyEval_InitThreads();"
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"/*--- Initialize various global constants etc. ---*/"
)
code
.
putln
(
code
.
error_goto_if_neg
(
"__Pyx_InitGlobals()"
,
self
.
pos
))
...
...
Cython/Compiler/Nodes.py
View file @
9687773f
...
...
@@ -1075,6 +1075,7 @@ class FuncDefNode(StatNode, BlockNode):
# ----- GIL acquisition
acquire_gil
=
self
.
need_gil_acquisition
(
lenv
)
if
acquire_gil
:
env
.
use_utility_code
(
py23_init_threads_utility_code
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
# ----- Automatic lead-ins for certain special functions
if
not
lenv
.
nogil
:
...
...
@@ -4528,6 +4529,7 @@ class GILStatNode(TryFinallyStatNode):
finally_clause
=
GILExitNode
(
pos
,
state
=
state
))
def
analyse_expressions
(
self
,
env
):
env
.
use_utility_code
(
py23_init_threads_utility_code
)
was_nogil
=
env
.
nogil
env
.
nogil
=
1
TryFinallyStatNode
.
analyse_expressions
(
self
,
env
)
...
...
@@ -5621,3 +5623,16 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb)
"""
)
#------------------------------------------------------------------------------------
py23_init_threads_utility_code
=
UtilityCode
(
proto
=
"""
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#if PY_VERSION_HEX < 0x02040000
#undef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 1
#endif
#endif
"""
)
#------------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment