@@ -132,7 +132,7 @@ PyWrapper::PyWrapper() {
132
132
_wrapperTest = _obj.attr (" wrapperTestFunc" );
133
133
134
134
py::gil_scoped_release release;
135
- // StartMonitorWrapperClass(_wrapper_abs);
135
+ // StartMonitorWrapperClass(_wrapper_abs);
136
136
137
137
}
138
138
@@ -252,7 +252,7 @@ int PyWrapper::wrapperFini() {
252
252
253
253
int PyWrapper::wrapperOnceExec (const char *usrTag, std::map <std::string, std::string> params, DataListCls reqData,
254
254
pDataList *respData, std::string sid, wrapperCallback cb, unsigned int psrId) {
255
- SetSidUsrTag (sid, usrTag);
255
+ // SetSidUsrTag(sid, usrTag);
256
256
try {
257
257
if (cb != nullptr ) {
258
258
SetSidCallBack (cb, sid);
@@ -353,7 +353,6 @@ int PyWrapper::wrapperOnceExecAsync(const char *usrTag, std::map <std::string, s
353
353
py::gil_scoped_acquire acquire;
354
354
355
355
int ret = 0 ;
356
- SetSidUsrTag (sid, usrTag);
357
356
params[" sid" ] = sid;
358
357
// 执行python exec 推理
359
358
py::object r = _wrapperOnceExecAsync (params, reqData, sid, psrId);
@@ -413,12 +412,11 @@ PyWrapper::wrapperCreate(const char *usrTag, std::map <std::string, std::string>
413
412
int *errNum, std::string sid, unsigned int psrId) {
414
413
SessionCreateResponse *resp;
415
414
SetSidCallBack (cb, sid);
416
- SetSidUsrTag (sid, usrTag);
417
415
418
416
try {
419
417
py::gil_scoped_acquire acquire;
420
418
// 此段根据python的返回 ,回写 respData
421
- py::object r = _wrapperCreate (params, sid, psrId);
419
+ py::object r = _wrapperCreate (params, sid, psrId, usrTag );
422
420
resp = r.cast <SessionCreateResponse *>();
423
421
*errNum = resp->errCode ;
424
422
if (*errNum != 0 ) {
@@ -439,11 +437,11 @@ PyWrapper::wrapperCreate(const char *usrTag, std::map <std::string, std::string>
439
437
}
440
438
441
439
// 上行数据
442
- int PyWrapper::wrapperWrite (char *handle, DataListCls reqData, std::string sid ) {
440
+ int PyWrapper::wrapperWrite (char *handle, DataListCls reqData) {
443
441
try {
444
442
int ret = 0 ;
445
443
// 执行python exec 推理
446
- py::object r = _wrapperWrite (handle, reqData, sid );
444
+ py::object r = _wrapperWrite (handle, reqData);
447
445
ret = r.cast <int >();
448
446
return ret;
449
447
}
@@ -458,12 +456,12 @@ int PyWrapper::wrapperWrite(char *handle, DataListCls reqData, std::string sid)
458
456
}
459
457
460
458
// 下行数据
461
- int PyWrapper::wrapperRead (char *handle, pDataList *respData, std::string sid ) {
459
+ int PyWrapper::wrapperRead (char *handle, pDataList *respData) {
462
460
try {
463
461
Response *resp;
464
462
// 执行python exec 推理
465
- py::object r = _wrapperRead (handle, sid );
466
- spdlog::debug (" start cast python resp to c++ object, thread_id: {}, sid : {}" , gettid (), sid );
463
+ py::object r = _wrapperRead (handle);
464
+ spdlog::debug (" start cast python resp to c++ object, thread_id: {}, handle : {}" , gettid (), handle );
467
465
resp = r.cast <Response *>();
468
466
pDataList headPtr;
469
467
pDataList curPtr;
@@ -492,7 +490,7 @@ int PyWrapper::wrapperRead(char *handle, pDataList *respData, std::string sid) {
492
490
pr = malloc (itemData.len );
493
491
if (pr == nullptr ) {
494
492
int ret = -1 ;
495
- spdlog::get (" stderr_console" )->error (" can't malloc memory for data, sid :{}" , sid );
493
+ spdlog::get (" stderr_console" )->error (" can't malloc memory for data, handle :{}" , handle );
496
494
return ret;
497
495
}
498
496
memcpy (pr, (const void *) itemData.data .ptr (), itemData.len );
@@ -507,9 +505,9 @@ int PyWrapper::wrapperRead(char *handle, pDataList *respData, std::string sid) {
507
505
curPtr->next = tmpData;
508
506
curPtr = tmpData;
509
507
}
510
- spdlog::debug (" get result,key:{},data:{},len:{},type:{},status:{},sid :{}" ,
508
+ spdlog::debug (" get result,key:{},data:{},len:{},type:{},status:{},handle :{}" ,
511
509
tmpData->key , (char *) tmpData->data , tmpData->len , tmpData->type ,
512
- tmpData->status , sid );
510
+ tmpData->status , handle );
513
511
}
514
512
*respData = headPtr;
515
513
}
@@ -524,20 +522,15 @@ int PyWrapper::wrapperRead(char *handle, pDataList *respData, std::string sid) {
524
522
return 0 ;
525
523
}
526
524
527
- int PyWrapper::wrapperDestroy (std::string sid, char * handle) {
528
- DelSidCallback (sid);
529
- DelSidUsrTag (sid);
525
+ int PyWrapper::wrapperDestroy (char * handle) {
530
526
py::object r = _wrapperDestroy (handle);
531
527
// 此段根据python的返回 ,回写 respData
532
- spdlog::info (" Destroy .. thread_id: {}, sid : {}" , gettid (), sid );
528
+ spdlog::info (" Destroy .. thread_id: {}, handle : {}" , gettid (), handle );
533
529
int ret = r.cast <int >();
534
530
return ret;
535
531
}
536
532
537
533
int PyWrapper::wrapperExecFree (const char *usrTag) {
538
- std::string sid = GetSidByUsrTag (usrTag);
539
- if (sid != " " )
540
- DelSidUsrTag (sid);
541
534
return 0 ;
542
535
}
543
536
@@ -626,15 +619,13 @@ int callbackTrace(const char *usrTag, const char *key, const char *value) {
626
619
return g_trace_cb (usrTag, key, value);
627
620
}
628
621
629
- int callBack (Response *resp, std::string sid ) {
622
+ int callBack (Response *resp, char *usrTag ) {
630
623
wrapperCallback cb_;
631
- cb_ = GetSidCB (sid) ;
624
+ cb_ = g_resp_cb ;
632
625
if (cb_ == NULL ) {
633
626
printf (" null cb....\n " );
634
627
return -1 ;
635
628
}
636
- const char *usrTag = GetSidUsrTag (sid);
637
-
638
629
pDataList headPtr;
639
630
pDataList curPtr;
640
631
int ret ;
@@ -664,7 +655,7 @@ int callBack(Response *resp, std::string sid) {
664
655
pr = malloc (itemData.len );
665
656
if (pr == nullptr ) {
666
657
int ret = -1 ;
667
- spdlog::get (" stderr_console" )->error (" can't malloc memory for data, sid :{}" , sid );
658
+ spdlog::get (" stderr_console" )->error (" can't malloc memory for data, usrTag :{}" , usrTag );
668
659
return ret;
669
660
}
670
661
ptr = PyBytes_AsString (itemData.data .ptr ());
@@ -682,13 +673,13 @@ int callBack(Response *resp, std::string sid) {
682
673
curPtr->next = tmpData;
683
674
curPtr = tmpData;
684
675
}
685
- spdlog::debug (" callback result,key:{},data:{},len:{},type:{},status:{},sid :{}" ,
676
+ spdlog::debug (" callback result,key:{},data:{},len:{},type:{},status:{},usrTag :{}" ,
686
677
tmpData->key , (char *) tmpData->data , tmpData->len , tmpData->type ,
687
- tmpData->status , sid );
678
+ tmpData->status , usrTag );
688
679
}
689
680
690
- cb_ (usrTag, headPtr, 0 );
691
- spdlog::debug (" call c's callback ok " );
681
+ int cb_ret = cb_ (usrTag, headPtr, 0 );
682
+ spdlog::debug (" call c's callback,usrTag:{} ret {} " ,usrTag, cb_ret );
692
683
return 0 ;
693
684
694
685
}
0 commit comments