You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After recently updating, I played around with py::gil_safe_call_once_and_store, and found it reasonably useful in avoiding the decref after finalization crash. However, it seems it does this by just having a leaking destructor. This is fine for a constant static reference, like in the stated example, but it's not so suitable for a more temporary reference which might get swapped out.
To explain further, a situation I've run into a lot is having C++ run Python callbacks out of band. A simplified example for console commands might look like:
Assuming it still holds a callback when the process quits, this map has the exact same decref after finalization issue as a standard static reference. But it's also completely expected that I might delete elements from it at runtime, and I don't want those to leak.
Previously I was actually storing my own wrapper type, which did the following.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
After recently updating, I played around with
py::gil_safe_call_once_and_store
, and found it reasonably useful in avoiding the decref after finalization crash. However, it seems it does this by just having a leaking destructor. This is fine for a constant static reference, like in the stated example, but it's not so suitable for a more temporary reference which might get swapped out.To explain further, a situation I've run into a lot is having C++ run Python callbacks out of band. A simplified example for console commands might look like:
Assuming it still holds a callback when the process quits, this map has the exact same decref after finalization issue as a standard static reference. But it's also completely expected that I might delete elements from it at runtime, and I don't want those to leak.
Previously I was actually storing my own wrapper type, which did the following.
For now it's looking like I need to keep it around for these sorts of situations. Is there any chance of seeing an "official" solution?
Beta Was this translation helpful? Give feedback.
All reactions