File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,17 @@ struct type_caster<std::function<Return(Args...)>> {
57
57
// ensure GIL is held during functor destruction
58
58
struct func_handle {
59
59
function f;
60
- func_handle (function&& f_) : f(std::move(f_)) {}
61
- func_handle (const func_handle&) = default ;
62
60
~func_handle () {
63
- gil_scoped_acquire acq;
64
- function kill_f (std::move (f));
61
+ PyGILState_STATE gstate;
62
+ gstate = PyGILState_Ensure ();
63
+ {
64
+ function kill_f (std::move (f));
65
+ }
66
+ PyGILState_Release (gstate);
65
67
}
66
68
};
67
69
68
- value = [hfunc = func_handle ( std::move ( func)) ](Args... args) -> Return {
70
+ value = [hfunc = func_handle{ func} ](Args... args) -> Return {
69
71
gil_scoped_acquire acq;
70
72
object retval (hfunc.f (std::forward<Args>(args)...));
71
73
/* Visual studio 2015 parser issue: need parentheses around this expression */
You can’t perform that action at this time.
0 commit comments