File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -429,15 +429,15 @@ impl PySessionContext {
429429 }
430430
431431 /// Returns a PyDataFrame whose plan corresponds to the SQL statement.
432- pub fn sql ( & mut self , query : & str , py : Python ) -> PyDataFusionResult < PyDataFrame > {
432+ pub fn sql ( & self , query : & str , py : Python ) -> PyDataFusionResult < PyDataFrame > {
433433 let result = self . ctx . sql ( query) ;
434434 let df = wait_for_future ( py, result) ??;
435435 Ok ( PyDataFrame :: new ( df) )
436436 }
437437
438438 #[ pyo3( signature = ( query, options=None ) ) ]
439439 pub fn sql_with_options (
440- & mut self ,
440+ & self ,
441441 query : & str ,
442442 options : Option < PySQLOptions > ,
443443 py : Python ,
Original file line number Diff line number Diff line change 8282 const INTERVAL_CHECK_SIGNALS : Duration = Duration :: from_millis ( 1_000 ) ;
8383
8484 py. allow_threads ( || {
85- runtime . block_on ( async {
85+ let wait_future = || async {
8686 tokio:: pin!( fut) ;
8787 loop {
8888 tokio:: select! {
9292 }
9393 }
9494 }
95- } )
95+ } ;
96+
97+ if tokio:: runtime:: Handle :: try_current ( ) . is_ok ( ) {
98+ tokio:: task:: block_in_place ( || runtime. block_on ( wait_future ( ) ) )
99+ } else {
100+ runtime. block_on ( wait_future ( ) )
101+ }
96102 } )
97103}
98104
You can’t perform that action at this time.
0 commit comments