Is there an existing proposal for this?
Is your feature request related to a problem?
Memray exposes a programmatic API for profiling, which needs to be thread-safe in order to run under free-threaded builds of Python.
Describe the solution you'd like
I don't think we need to worry about scaling too much. Critical sections should definitely work for Cython code, especially since they now have free-threading support.
For Memray's C++ code, critical sections probably won't work (because a lot of global state isn't owned by objects), so some global PyMutex locks will probably end up being the best choice.
I'll begin working on this sometime soon.
Alternatives you considered
No response
Is there an existing proposal for this?
Is your feature request related to a problem?
Memray exposes a programmatic API for profiling, which needs to be thread-safe in order to run under free-threaded builds of Python.
Describe the solution you'd like
I don't think we need to worry about scaling too much. Critical sections should definitely work for Cython code, especially since they now have free-threading support.
For Memray's C++ code, critical sections probably won't work (because a lot of global state isn't owned by objects), so some global
PyMutexlocks will probably end up being the best choice.I'll begin working on this sometime soon.
Alternatives you considered
No response