[Python-bugs-list] [ python-Feature Requests-443775 ] Update to the BEGIN_ALLOW_THREADS macros

SourceForge.net noreply@sourceforge.net
Fri, 17 Jan 2003 21:16:18 -0800


Feature Requests item #443775, was opened at 2001-07-23 16:34
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=443775&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Sjögren (msjogren)
Assigned to: Nobody/Anonymous (nobody)
Summary: Update to the BEGIN_ALLOW_THREADS macros

Initial Comment:
The Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS
currently do not support supplying WHERE to save the
thread state via an argument. I needed that for a
project myself so I wrote the following:

#ifdef WITH_THREAD
#  define MY_BEGIN_ALLOW_THREADS(st)    \
    { st = PyEval_SaveThread(); }
#  define MY_END_ALLOW_THREADS(st)      \
    { PyEval_RestoreThread(st); st = NULL; }
#else
#  define MY_BEGIN_ALLOW_THREADS(st)
#  define MY_END_ALLOW_THREADS(st)      { st = NULL; }
#endif

This has, of course, the drawback that whenever the
Py_BEGIN_ALLOW_THREADS macro changes I have to change mine!

Therefore, I propose that these macros (under different
names certainly) or macros that work something like
this (I can't have asymmetric { and } in them, since I
needed to retrieve the thread state somewhere else) in
the standard Python distribution.

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

Comment By: Michael Dubner (dubnerm)
Date: 2003-01-18 08:16

Message:
Logged In: YES 
user_id=39274

I think that current Py_BEGIN/END_ALLOW_THREADS macroses
model (with block) is choosen to enforce compile-time
pairwise check. Isn't it?

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

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