@@ -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 ( ) {
@@ -361,12 +365,15 @@ impl ClientRef {
361365 ) ) )
362366 }
363367 } ?;
364- let bytes: & [ u8 ] = & bytes;
365- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
368+ Ok ( bytes)
366369 } )
367370 }
368371
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 > > {
370377 use temporal_client:: OperatorService ;
371378
372379 let mut retry_client = self . retry_client . clone ( ) ;
@@ -403,12 +410,11 @@ impl ClientRef {
403410 ) ) )
404411 }
405412 } ?;
406- let bytes: & [ u8 ] = & bytes;
407- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
413+ Ok ( bytes)
408414 } )
409415 }
410416
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 > > {
412418 use temporal_client:: CloudService ;
413419
414420 let mut retry_client = self . retry_client . clone ( ) ;
@@ -466,12 +472,11 @@ impl ClientRef {
466472 ) ) )
467473 }
468474 } ?;
469- let bytes: & [ u8 ] = & bytes;
470- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
475+ Ok ( bytes)
471476 } )
472477 }
473478
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 > > {
475480 let mut retry_client = self . retry_client . clone ( ) ;
476481 self . runtime . future_into_py ( py, async move {
477482 let bytes = match call. rpc . as_str ( ) {
@@ -490,12 +495,11 @@ impl ClientRef {
490495 ) ) )
491496 }
492497 } ?;
493- let bytes: & [ u8 ] = & bytes;
494- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
498+ Ok ( bytes)
495499 } )
496500 }
497501
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 > > {
499503 let mut retry_client = self . retry_client . clone ( ) ;
500504 self . runtime . future_into_py ( py, async move {
501505 let bytes = match call. rpc . as_str ( ) {
@@ -507,8 +511,7 @@ impl ClientRef {
507511 ) ) )
508512 }
509513 } ?;
510- let bytes: & [ u8 ] = & bytes;
511- Ok ( Python :: with_gil ( |py| bytes. into_py ( py) ) )
514+ Ok ( bytes)
512515 } )
513516 }
514517}
@@ -539,13 +542,13 @@ where
539542 match res {
540543 Ok ( resp) => Ok ( resp. get_ref ( ) . encode_to_vec ( ) ) ,
541544 Err ( err) => {
542- Err ( Python :: with_gil ( move |py| {
545+ Python :: with_gil ( move |py| {
543546 // Create tuple of "status", "message", and optional "details"
544547 let code = err. code ( ) as u32 ;
545548 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+ } )
549552 }
550553 }
551554}
0 commit comments