[ python-Bugs-1011380 ] Make GIL acquire/release functions noops if PyEval_Init

SourceForge.net noreply at sourceforge.net
Sun Oct 10 17:47:21 CEST 2004


Bugs item #1011380, was opened at 2004-08-18 22:07
Message generated for change (Comment added) made by ncoghlan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1011380&group_id=5470

Category: Threads
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Gustavo J. A. M. Carneiro (gustavo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Make GIL acquire/release functions noops if PyEval_Init

Initial Comment:
The patch makes GIL acquire/release functions
idempotent if PyEval_InitThreads hasn't been called.

Motivation for this change can be found in my post to
python-dev, here: 

http://mail.python.org/pipermail/python-dev/2004-August/047870.html
http://mail.python.org/pipermail/python-dev/2004-August/047871.html

Some feedback here:
http://mail.python.org/pipermail/python-dev/2004-August/047949.html


----------------------------------------------------------------------

Comment By: Nick Coghlan (ncoghlan)
Date: 2004-10-11 01:47

Message:
Logged In: YES 
user_id=1038590

The patch doesn't apply cleanly to current CVS (no actual
conflict that I can see - just the patch machinery getting
confused by a cautionary comment added to the top of pystate.c)

Inspecting the patch manually, it looks like it does the
right thing, given that Python instructs that Py_Initialise
and PyEval_InitThreads *both* be called prior while the
application is still single-threaded.

However, _PyThread_Started seems like an odd bit of code -
prior to this patch, it is set (initialised to 0 in
pythonrun.c, set to 1 by PyEval_InitThreads), but never
referenced anywhere (despite the comment saying that it is a
"Flag for Py_Exit").

It's also not part of any API (even an internal one). It is
defined in pythonrun.c, then declared as extern in ceval.c.
The patch adds another extern declaration in pystate.c

It would seem better (and only slightly more work) to add a
real API (such as adding PyThread_IsInitialized() to
pythread.h), rather than entrenching further use of
_PyThread_Started.


----------------------------------------------------------------------

Comment By: Gustavo J. A. M. Carneiro (gustavo)
Date: 2004-09-29 00:25

Message:
Logged In: YES 
user_id=908

Can someone please take a look at this patch?  It's fairly
simple, but very important.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1011380&group_id=5470


More information about the Python-bugs-list mailing list