@@ -80,7 +80,7 @@ pub fn connect_client<'a>(
80
80
py : Python < ' a > ,
81
81
runtime_ref : & runtime:: RuntimeRef ,
82
82
config : ClientConfig ,
83
- ) -> PyResult < & ' a PyAny > {
83
+ ) -> PyResult < Bound < ' a , PyAny > > {
84
84
let opts: ClientOptions = config. try_into ( ) ?;
85
85
let runtime = runtime_ref. runtime . clone ( ) ;
86
86
runtime_ref. runtime . future_into_py ( py, async move {
@@ -126,7 +126,11 @@ impl ClientRef {
126
126
self . retry_client . get_client ( ) . set_api_key ( api_key) ;
127
127
}
128
128
129
- fn call_workflow_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
129
+ fn call_workflow_service < ' p > (
130
+ & self ,
131
+ py : Python < ' p > ,
132
+ call : RpcCall ,
133
+ ) -> PyResult < Bound < ' p , PyAny > > {
130
134
let mut retry_client = self . retry_client . clone ( ) ;
131
135
self . runtime . future_into_py ( py, async move {
132
136
let bytes = match call. rpc . as_str ( ) {
@@ -361,12 +365,15 @@ impl ClientRef {
361
365
) ) )
362
366
}
363
367
} ?;
364
- let bytes: & [ u8 ] = & bytes;
365
- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
368
+ Ok ( bytes)
366
369
} )
367
370
}
368
371
369
- fn call_operator_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
372
+ fn call_operator_service < ' p > (
373
+ & self ,
374
+ py : Python < ' p > ,
375
+ call : RpcCall ,
376
+ ) -> PyResult < Bound < ' p , PyAny > > {
370
377
use temporal_client:: OperatorService ;
371
378
372
379
let mut retry_client = self . retry_client . clone ( ) ;
@@ -403,12 +410,11 @@ impl ClientRef {
403
410
) ) )
404
411
}
405
412
} ?;
406
- let bytes: & [ u8 ] = & bytes;
407
- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
413
+ Ok ( bytes)
408
414
} )
409
415
}
410
416
411
- fn call_cloud_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
417
+ fn call_cloud_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
412
418
use temporal_client:: CloudService ;
413
419
414
420
let mut retry_client = self . retry_client . clone ( ) ;
@@ -466,12 +472,11 @@ impl ClientRef {
466
472
) ) )
467
473
}
468
474
} ?;
469
- let bytes: & [ u8 ] = & bytes;
470
- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
475
+ Ok ( bytes)
471
476
} )
472
477
}
473
478
474
- fn call_test_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
479
+ fn call_test_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
475
480
let mut retry_client = self . retry_client . clone ( ) ;
476
481
self . runtime . future_into_py ( py, async move {
477
482
let bytes = match call. rpc . as_str ( ) {
@@ -490,12 +495,11 @@ impl ClientRef {
490
495
) ) )
491
496
}
492
497
} ?;
493
- let bytes: & [ u8 ] = & bytes;
494
- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
498
+ Ok ( bytes)
495
499
} )
496
500
}
497
501
498
- fn call_health_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
502
+ fn call_health_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
499
503
let mut retry_client = self . retry_client . clone ( ) ;
500
504
self . runtime . future_into_py ( py, async move {
501
505
let bytes = match call. rpc . as_str ( ) {
@@ -507,8 +511,7 @@ impl ClientRef {
507
511
) ) )
508
512
}
509
513
} ?;
510
- let bytes: & [ u8 ] = & bytes;
511
- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
514
+ Ok ( bytes)
512
515
} )
513
516
}
514
517
}
@@ -539,13 +542,13 @@ where
539
542
match res {
540
543
Ok ( resp) => Ok ( resp. get_ref ( ) . encode_to_vec ( ) ) ,
541
544
Err ( err) => {
542
- Err ( Python :: with_gil ( move |py| {
545
+ Python :: with_gil ( move |py| {
543
546
// Create tuple of "status", "message", and optional "details"
544
547
let code = err. code ( ) as u32 ;
545
548
let message = err. message ( ) . to_owned ( ) ;
546
- let details = err. details ( ) . into_py ( py) ;
547
- RPCError :: new_err ( ( code, message, details) )
548
- } ) )
549
+ let details = err. details ( ) . into_pyobject ( py) ? . unbind ( ) ;
550
+ Err ( RPCError :: new_err ( ( code, message, details) ) )
551
+ } )
549
552
}
550
553
}
551
554
}
0 commit comments