@@ -80,7 +80,7 @@ pub fn connect_client<'a>(
8080 py : Python < ' a > ,
8181 runtime_ref : & runtime:: RuntimeRef ,
8282 config : ClientConfig ,
83- ) -> PyResult < & ' a PyAny > {
83+ ) -> PyResult < Bound < ' a , PyAny > > {
8484 let opts: ClientOptions = config. try_into ( ) ?;
8585 let runtime = runtime_ref. runtime . clone ( ) ;
8686 runtime_ref. runtime . future_into_py ( py, async move {
@@ -126,7 +126,11 @@ impl ClientRef {
126126 self . retry_client . get_client ( ) . set_api_key ( api_key) ;
127127 }
128128
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 > > {
130134 let mut retry_client = self . retry_client . clone ( ) ;
131135 self . runtime . future_into_py ( py, async move {
132136 let bytes = match call. rpc . as_str ( ) {
@@ -364,12 +368,15 @@ impl ClientRef {
364368 ) ) )
365369 }
366370 } ?;
367- let bytes: & [ u8 ] = & bytes;
368- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
371+ Ok ( bytes)
369372 } )
370373 }
371374
372- fn call_operator_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
375+ fn call_operator_service < ' p > (
376+ & self ,
377+ py : Python < ' p > ,
378+ call : RpcCall ,
379+ ) -> PyResult < Bound < ' p , PyAny > > {
373380 use temporal_client:: OperatorService ;
374381
375382 let mut retry_client = self . retry_client . clone ( ) ;
@@ -406,12 +413,11 @@ impl ClientRef {
406413 ) ) )
407414 }
408415 } ?;
409- let bytes: & [ u8 ] = & bytes;
410- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
416+ Ok ( bytes)
411417 } )
412418 }
413419
414- fn call_cloud_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
420+ fn call_cloud_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
415421 use temporal_client:: CloudService ;
416422
417423 let mut retry_client = self . retry_client . clone ( ) ;
@@ -469,12 +475,11 @@ impl ClientRef {
469475 ) ) )
470476 }
471477 } ?;
472- let bytes: & [ u8 ] = & bytes;
473- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
478+ Ok ( bytes)
474479 } )
475480 }
476481
477- fn call_test_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
482+ fn call_test_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
478483 let mut retry_client = self . retry_client . clone ( ) ;
479484 self . runtime . future_into_py ( py, async move {
480485 let bytes = match call. rpc . as_str ( ) {
@@ -493,12 +498,11 @@ impl ClientRef {
493498 ) ) )
494499 }
495500 } ?;
496- let bytes: & [ u8 ] = & bytes;
497- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
501+ Ok ( bytes)
498502 } )
499503 }
500504
501- fn call_health_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < & ' p PyAny > {
505+ fn call_health_service < ' p > ( & self , py : Python < ' p > , call : RpcCall ) -> PyResult < Bound < ' p , PyAny > > {
502506 let mut retry_client = self . retry_client . clone ( ) ;
503507 self . runtime . future_into_py ( py, async move {
504508 let bytes = match call. rpc . as_str ( ) {
@@ -510,8 +514,7 @@ impl ClientRef {
510514 ) ) )
511515 }
512516 } ?;
513- let bytes: & [ u8 ] = & bytes;
514- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
517+ Ok ( bytes)
515518 } )
516519 }
517520}
@@ -542,13 +545,13 @@ where
542545 match res {
543546 Ok ( resp) => Ok ( resp. get_ref ( ) . encode_to_vec ( ) ) ,
544547 Err ( err) => {
545- Err ( Python :: with_gil ( move |py| {
548+ Python :: with_gil ( move |py| {
546549 // Create tuple of "status", "message", and optional "details"
547550 let code = err. code ( ) as u32 ;
548551 let message = err. message ( ) . to_owned ( ) ;
549- let details = err. details ( ) . into_py ( py) ;
550- RPCError :: new_err ( ( code, message, details) )
551- } ) )
552+ let details = err. details ( ) . into_pyobject ( py) ? . unbind ( ) ;
553+ Err ( RPCError :: new_err ( ( code, message, details) ) )
554+ } )
552555 }
553556 }
554557}
0 commit comments