[Python-Dev] BEGIN_ALLOW_THREADS
Martin Sjögren
martin@strakt.com
Mon, 23 Jul 2001 14:21:57 +0200
Hello
Is there a reason the Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS
don't allow an argument specifying what variable to save the state to? I
needed this myself so I wrote the following:
#ifdef WITH_THREAD
# define MY_BEGIN_ALLOW_THREADS(st) \
{ st =3D PyEval_SaveThread(); }
# define MY_END_ALLOW_THREADS(st) \
{ PyEval_RestoreThread(st); st =3D NULL; }
#else
# define MY_BEGIN_ALLOW_THREADS(st)
# define MY_END_ALLOW_THREADS(st) { st =3D NULL; }
#endif
It works just fine but has one drawback: Whenever Py_BEGIN_ALLOW_THREADS
changes, I have to change my macros too.
Wouldn't it be reasonable to supply two sets of macros, one that allows
exactly this, and one that does what Py_BEGIN_ALLOW_THREADS currently
does.
Martin Sj=F6gren
--=20
Martin Sj=F6gren
martin@strakt.com ICQ : 41245059
Phone: +46 (0)31 405242 Cell: +46 (0)739 169191
GPG key: http://www.strakt.com/~martin/gpg.html