Skip to content

Commit 55cb002

Browse files
committed
destroy logic
1 parent c581e35 commit 55cb002

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pyWrapper.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ PyWrapper::PyWrapper() {
128128
_wrapperCreate = _obj.attr("wrapperCreate");
129129
_wrapperWrite = _obj.attr("wrapperWrite");
130130
_wrapperRead = _obj.attr("wrapperRead");
131+
_wrapperDestroy = _obj.attr("wrapperDestroy");
131132
_wrapperTest = _obj.attr("wrapperTestFunc");
132133

133134
py::gil_scoped_release release;
@@ -521,10 +522,14 @@ int PyWrapper::wrapperRead(char *handle, pDataList *respData, std::string sid) {
521522
return 0;
522523
}
523524

524-
int PyWrapper::wrapperDestroy(std::string sid) {
525+
int PyWrapper::wrapperDestroy(std::string sid, char * handle) {
525526
DelSidCallback(sid);
526527
DelSidUsrTag(sid);
527-
return 0;
528+
py::object r = _wrapperDestroy(handle);
529+
// 此段根据python的返回 ,回写 respData
530+
spdlog::info("Destroy .. thread_id: {}, sid: {}", gettid(), sid);
531+
ret = r.cast<int>();
532+
return ret;
528533
}
529534

530535
int PyWrapper::wrapperExecFree(const char *usrTag) {

pyWrapper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class PyWrapper {
142142

143143
int wrapperRead(char *handle, pDataList *respData, std::string sid);
144144

145-
int wrapperDestroy(std::string sid);
145+
int wrapperDestroy(std::string sid, char * handle);
146146

147147
int wrapperExecFree(const char *usrTag);
148148

@@ -166,6 +166,8 @@ class PyWrapper {
166166
py::object _wrapperOnceExecAsync;
167167
py::object _wrapperError;
168168
py::object _wrapperCreate;
169+
py::object _wrapperDestroy;
170+
169171
py::object _wrapperWrite;
170172
py::object _wrapperRead;
171173
py::object _wrapperLoadRes;

wrapper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ int WrapperAPI wrapperRead(const void *handle, pDataList *respData) {
286286

287287
int WrapperAPI wrapperDestroy(const void *handle) {
288288
int ret = 0;
289+
py::gil_scoped_acquire acquire;
289290
std::string sid = GetHandleSid((char *) handle);
290-
ret = pyWrapper->wrapperDestroy(sid);
291+
ret = pyWrapper->wrapperDestroy(sid, (char *) handle);
291292
if (ret != 0) {
292293
spdlog::get("stderr_console")->error("wrapper destroy error!");
293294
}

0 commit comments

Comments
 (0)