@@ -11,14 +11,15 @@ const char *wrapperFileClass = "wrapper.class";
1111const char *WrapperFile = " wrapper" ;
1212const char *WrapperClass = " Wrapper" ;
1313const char *PythonSo = " libpython3.so" ;
14+ wrapperMeterCustom g_metric_cb;
1415
1516std::mutex RECORD_MUTEX;
1617std::map <std::string, std::string> SID_RECORD;
1718std::map <std::string, wrapperCallback> SID_CB;
1819std::map<std::string, const char *> SID_USRTAG;
1920
2021PYBIND11_EMBEDDED_MODULE (aiges_embed, module ) {
21- module .def (" callback_metric" , &PyWrapper:: callbackMetric, py::return_value_policy::automatic_reference);
22+ module .def (" callback_metric" , &callbackMetric, py::return_value_policy::automatic_reference);
2223 module .def (" callback" , &callBack, py::return_value_policy::automatic_reference);
2324 py::class_<ResponseData> responseData (module , " ResponseData" );
2425 responseData.def (py::init<>())
@@ -246,7 +247,7 @@ int PyWrapper::wrapperOnceExec(const char *usrTag, std::map <std::string, std::s
246247
247248 py::gil_scoped_acquire acquire;
248249 // 执行python exec 推理
249- py::object r = _wrapperOnceExec (params, reqData);
250+ py::object r = _wrapperOnceExec (params, reqData, usrTag );
250251 // 此段根据python的返回 ,回写 respData
251252 Response *resp;
252253 spdlog::debug (" start cast python resp to c++ object, thread_id: {}, sid: {}" , gettid (), sid);
@@ -370,7 +371,7 @@ std::string PyWrapper::wrapperError(int err) {
370371
371372int PyWrapper::wrapperSetCtrl (CtrlType type, wrapperMeterCustom mc) {
372373 if (type == CTMeterCustom) {
373- metric_cb = mc;
374+ g_metric_cb = mc;
374375 }
375376 return 0 ;
376377}
@@ -544,8 +545,9 @@ int PyWrapper::wrapperTest() {
544545
545546}
546547
547- int PyWrapper::callbackMetric (const void *usrTag, const char *meterKey, int count) {
548- return metric_cb (usrTag, meterKey, count);
548+ int callbackMetric (const char *usrTag, const char *meterKey, int count) {
549+ printf (" %s, %s, %d\n " , usrTag, meterKey, count);
550+ return g_metric_cb (usrTag, meterKey, count);
549551}
550552
551553int callBack (Response *resp, std::string sid) {
0 commit comments