@@ -88,7 +88,7 @@ impl PyCatalog {
8888 "Schema with name {name} doesn't exist."
8989 ) ) ) ?;
9090
91- Python :: with_gil ( |py| {
91+ Python :: attach ( |py| {
9292 match schema
9393 . as_any ( )
9494 . downcast_ref :: < RustWrappedPySchemaProvider > ( )
@@ -207,7 +207,7 @@ pub(crate) struct RustWrappedPySchemaProvider {
207207
208208impl RustWrappedPySchemaProvider {
209209 pub fn new ( schema_provider : PyObject ) -> Self {
210- let owner_name = Python :: with_gil ( |py| {
210+ let owner_name = Python :: attach ( |py| {
211211 schema_provider
212212 . bind ( py)
213213 . getattr ( "owner_name" )
@@ -222,7 +222,7 @@ impl RustWrappedPySchemaProvider {
222222 }
223223
224224 fn table_inner ( & self , name : & str ) -> PyResult < Option < Arc < dyn TableProvider > > > {
225- Python :: with_gil ( |py| {
225+ Python :: attach ( |py| {
226226 let provider = self . schema_provider . bind ( py) ;
227227 let py_table_method = provider. getattr ( "table" ) ?;
228228
@@ -249,7 +249,7 @@ impl SchemaProvider for RustWrappedPySchemaProvider {
249249 }
250250
251251 fn table_names ( & self ) -> Vec < String > {
252- Python :: with_gil ( |py| {
252+ Python :: attach ( |py| {
253253 let provider = self . schema_provider . bind ( py) ;
254254
255255 provider
@@ -275,7 +275,7 @@ impl SchemaProvider for RustWrappedPySchemaProvider {
275275 table : Arc < dyn TableProvider > ,
276276 ) -> datafusion:: common:: Result < Option < Arc < dyn TableProvider > > > {
277277 let py_table = PyTable :: from ( table) ;
278- Python :: with_gil ( |py| {
278+ Python :: attach ( |py| {
279279 let provider = self . schema_provider . bind ( py) ;
280280 let _ = provider
281281 . call_method1 ( "register_table" , ( name, py_table) )
@@ -291,7 +291,7 @@ impl SchemaProvider for RustWrappedPySchemaProvider {
291291 & self ,
292292 name : & str ,
293293 ) -> datafusion:: common:: Result < Option < Arc < dyn TableProvider > > > {
294- Python :: with_gil ( |py| {
294+ Python :: attach ( |py| {
295295 let provider = self . schema_provider . bind ( py) ;
296296 let table = provider
297297 . call_method1 ( "deregister_table" , ( name, ) )
@@ -312,7 +312,7 @@ impl SchemaProvider for RustWrappedPySchemaProvider {
312312 }
313313
314314 fn table_exist ( & self , name : & str ) -> bool {
315- Python :: with_gil ( |py| {
315+ Python :: attach ( |py| {
316316 let provider = self . schema_provider . bind ( py) ;
317317 provider
318318 . call_method1 ( "table_exist" , ( name, ) )
@@ -333,7 +333,7 @@ impl RustWrappedPyCatalogProvider {
333333 }
334334
335335 fn schema_inner ( & self , name : & str ) -> PyResult < Option < Arc < dyn SchemaProvider > > > {
336- Python :: with_gil ( |py| {
336+ Python :: attach ( |py| {
337337 let provider = self . catalog_provider . bind ( py) ;
338338
339339 let py_schema = provider. call_method1 ( "schema" , ( name, ) ) ?;
@@ -378,7 +378,7 @@ impl CatalogProvider for RustWrappedPyCatalogProvider {
378378 }
379379
380380 fn schema_names ( & self ) -> Vec < String > {
381- Python :: with_gil ( |py| {
381+ Python :: attach ( |py| {
382382 let provider = self . catalog_provider . bind ( py) ;
383383 provider
384384 . getattr ( "schema_names" )
@@ -402,9 +402,7 @@ impl CatalogProvider for RustWrappedPyCatalogProvider {
402402 name : & str ,
403403 schema : Arc < dyn SchemaProvider > ,
404404 ) -> datafusion:: common:: Result < Option < Arc < dyn SchemaProvider > > > {
405- // JRIGHT HERE
406- // let py_schema: PySchema = schema.into();
407- Python :: with_gil ( |py| {
405+ Python :: attach ( |py| {
408406 let py_schema = match schema
409407 . as_any ( )
410408 . downcast_ref :: < RustWrappedPySchemaProvider > ( )
@@ -435,7 +433,7 @@ impl CatalogProvider for RustWrappedPyCatalogProvider {
435433 name : & str ,
436434 cascade : bool ,
437435 ) -> datafusion:: common:: Result < Option < Arc < dyn SchemaProvider > > > {
438- Python :: with_gil ( |py| {
436+ Python :: attach ( |py| {
439437 let provider = self . catalog_provider . bind ( py) ;
440438 let schema = provider
441439 . call_method1 ( "deregister_schema" , ( name, cascade) )
0 commit comments