[python] Proposal: RAII for Global Interpreter Lock (GIL)

There are many questions and example classes online for dealing with Python's Global Interpreter Lock (GIL) using RAII. I think Boost.Python should provide this functionality, rather than having users who build hybrid C++/Python applications copy-pasting code from various places. I was one of those users recently, and the code I developed to deal with it is now public: https://github.com/jzwinck/pccl/blob/master/InterpreterLockGuard.hpp https://github.com/jzwinck/pccl/blob/master/InterpreterLockGuard.cpp https://github.com/jzwinck/pccl/blob/master/test/InterpreterLockGuard.test.c... Comments in the header explain how to use it in the context of Boost.Python, and contain a link to a wiki from which some of the code was originally copied. Why add this to Boost? It's clearly code that a bunch of people need, often people who are already using Boost.Python. It has a permissive license, and I can re-license it if need be. And it depends on Boost (mostly for thread-specific storage--I hope this dependency won't be seen as a liability here, though it could be removed if needed). This particular implementation was used successfully in a few programs in a commercial setting on Fedora and RHEL systems. It has some extra checks that we found helpful compared to some of the versions you'll find posted online. The code also builds and passes its tests with GCC on Mac OS X. I welcome any feedback regarding the suitability for inclusion in Boost of this particular code and/or the concepts it implements. John Zwinck

on Fri Dec 14 2012, John Zwinck <jzwinck-AT-gmail.com> wrote:
There are many questions and example classes online for dealing with Python's Global Interpreter Lock (GIL) using RAII. I think Boost.Python should provide this functionality, rather than having users who build hybrid C++/Python applications copy-pasting code from various places. I was one of those users recently, and the code I developed to deal with it is now public:
<snip>
I welcome any feedback regarding the suitability for inclusion in Boost of this particular code and/or the concepts it implements.
Hi John, I haven't looked at the code but this sounds like a good idea to me. I suggest you post to http://beta.boost.org/community/groups.html#cplussig and/or open a ticket in Trac; it's likely to get more attention from the current maintainers. -- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost

On 16/12/2012 01:39, Dave Abrahams wrote:
I haven't looked at the code but this sounds like a good idea to me. I suggest you post to http://beta.boost.org/community/groups.html#cplussig and/or open a ticket in Trac; it's likely to get more attention from the current maintainers.
Thank you. I have done both. The Trac ticket is here, for reference: https://svn.boost.org/trac/boost/ticket/7836
participants (2)
-
Dave Abrahams
-
John Zwinck