Commit 961b2e62 by Hyrum Wright Committed by GitHub

fix: ensure the GIL is held when copying a function. (#2545)

Co-authored-by: Hyrum Wright <hwright@google.com>
parent 1bcd5f0a
...@@ -58,7 +58,10 @@ public: ...@@ -58,7 +58,10 @@ public:
struct func_handle { struct func_handle {
function f; function f;
func_handle(function&& f_) : f(std::move(f_)) {} func_handle(function&& f_) : f(std::move(f_)) {}
func_handle(const func_handle&) = default; func_handle(const func_handle& f_) {
gil_scoped_acquire acq;
f = f_.f;
}
~func_handle() { ~func_handle() {
gil_scoped_acquire acq; gil_scoped_acquire acq;
function kill_f(std::move(f)); function kill_f(std::move(f));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment