We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 978d439 commit cfab0d3Copy full SHA for cfab0d3
include/pybind11/functional.h
@@ -54,9 +54,11 @@ struct type_caster<std::function<Return(Args...)>> {
54
}
55
56
57
- value = [func](Args... args) -> Return {
+ value = [func](Args... args) mutable -> Return {
58
gil_scoped_acquire acq;
59
- object retval(func(std::forward<Args>(args)...));
+ // move into local var to ensure GIL is released AFTER functor destructor is called
60
+ function f(std::move(func));
61
+ object retval(f(std::forward<Args>(args)...));
62
/* Visual studio 2015 parser issue: need parentheses around this expression */
63
return (retval.template cast<Return>());
64
};
0 commit comments