ShannonDing commented on a change in pull request #20: Fixed deadlock, and add
args field for python callback.
URL:
https://github.com/apache/rocketmq-client-python/pull/20#discussion_r243808481
##########
File path: src/PythonWrapper.cpp
##########
@@ -30,24 +31,37 @@ using namespace std;
const char *VERSION =
"PYTHON_CLIENT_VERSION: " PYTHON_CLIENT_VERSION ", BUILD DATE: "
PYCLI_BUILD_DATE " ";
-map<CPushConsumer *, PyObject *> g_CallBackMap;
+map<CPushConsumer *, pair<PyObject *, object>> g_CallBackMap;
class PyThreadStateLock {
public:
- PyThreadStateLock(void) {
+ PyThreadStateLock() {
state = PyGILState_Ensure();
}
- ~PyThreadStateLock(void) {
- if (state == PyGILState_LOCKED) {
- PyGILState_Release(state);
- }
+ ~PyThreadStateLock() {
+ // NOTE: 必须跟 PyGILState_Ensure 成对出现,否则可能出现死锁!!!
+ PyGILState_Release(state);
Review comment:
Sometimes, the state of the GIL is not PyGILState_LOCKED, and the function
PyGILState_Release will crash. Did you find this before?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services