Opened 10 years ago

#7836 new Patches

Add GIL RAII module to Boost.Python

Reported by: John Zwinck <jzwinck@…> Owned by: Ralf W. Grosse-Kunstleve
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost Development Trunk Severity: Not Applicable
Keywords: GIL Cc:

Description

This ticket follows a recent discussion I started on the Python C++ SIG mailing list (which in turn followed a brief topic on the Boost developers list).

I would like to submit for inclusion in Boost.Python a pair of classes for releasing and acquiring the Python Global Interpreter Lock (GIL) using RAII semantics.

Please see three files attached to this ticket: gil.hpp, gil.cpp, and gil_test.cpp, which implement and (lightly) test this new feature. They are modified from versions I maintain on GitHub in order to make them more compatible with existing code style in Boost.Python.

This code (with different naming conventions but the same logic) has been used successfully by me "in production" and the releaser class is inspired by several examples online that others have until now copy-pasted when needed.

Attachments (3)

gil.hpp (1.6 KB ) - added by John Zwinck <jzwinck@…> 10 years ago.
Header file proposed for <boost/python/gil.hpp>
gil.cpp (1.6 KB ) - added by John Zwinck <jzwinck@…> 10 years ago.
Implementation for <boost/python/gil.hpp>
gil_test.cpp (757 bytes ) - added by John Zwinck <jzwinck@…> 10 years ago.
Test for <boost/python/gil.hpp>

Download all attachments as: .zip

Change History (3)

by John Zwinck <jzwinck@…>, 10 years ago

Attachment: gil.hpp added

Header file proposed for <boost/python/gil.hpp>

by John Zwinck <jzwinck@…>, 10 years ago

Attachment: gil.cpp added

Implementation for <boost/python/gil.hpp>

by John Zwinck <jzwinck@…>, 10 years ago

Attachment: gil_test.cpp added

Test for <boost/python/gil.hpp>

Note: See TracTickets for help on using tickets.