@@ -36,11 +36,11 @@ impl StoreInput {
3636/// https://developmentseed.org/obspec/latest/api/get/#obspec.GetRangeAsync
3737/// https://developmentseed.org/obspec/latest/api/get/#obspec.GetRangesAsync
3838#[ derive( Debug ) ]
39- pub ( crate ) struct ObspecBackend ( PyObject ) ;
39+ pub ( crate ) struct ObspecBackend ( Py < PyAny > ) ;
4040
4141impl ObspecBackend {
4242 async fn get_range ( & self , path : & str , range : Range < u64 > ) -> PyResult < PyBytes > {
43- let future = Python :: with_gil ( |py| {
43+ let future = Python :: attach ( |py| {
4444 let kwargs = PyDict :: new ( py) ;
4545 kwargs. set_item ( intern ! ( py, "path" ) , path) ?;
4646 kwargs. set_item ( intern ! ( py, "start" ) , range. start ) ?;
@@ -52,14 +52,14 @@ impl ObspecBackend {
5252 into_future ( coroutine. bind ( py) . clone ( ) )
5353 } ) ?;
5454 let result = future. await ?;
55- Python :: with_gil ( |py| result. extract ( py) )
55+ Python :: attach ( |py| result. extract ( py) )
5656 }
5757
5858 async fn get_ranges ( & self , path : & str , ranges : & [ Range < u64 > ] ) -> PyResult < Vec < PyBytes > > {
5959 let starts = ranges. iter ( ) . map ( |r| r. start ) . collect :: < Vec < _ > > ( ) ;
6060 let ends = ranges. iter ( ) . map ( |r| r. end ) . collect :: < Vec < _ > > ( ) ;
6161
62- let future = Python :: with_gil ( |py| {
62+ let future = Python :: attach ( |py| {
6363 let kwargs = PyDict :: new ( py) ;
6464 kwargs. set_item ( intern ! ( py, "path" ) , path) ?;
6565 kwargs. set_item ( intern ! ( py, "starts" ) , starts) ?;
@@ -71,7 +71,7 @@ impl ObspecBackend {
7171 into_future ( coroutine. bind ( py) . clone ( ) )
7272 } ) ?;
7373 let result = future. await ?;
74- Python :: with_gil ( |py| result. extract ( py) )
74+ Python :: attach ( |py| result. extract ( py) )
7575 }
7676
7777 async fn get_range_wrapper ( & self , path : & str , range : Range < u64 > ) -> AsyncTiffResult < Bytes > {
0 commit comments