@@ -80,7 +80,10 @@ impl PyRuntime {
8080 args,
8181 callback : PyScheduledCallback :: Channel ( rx) ,
8282 } )
83- . await ?;
83+ . await
84+ . map_err ( |err| {
85+ CubeError :: internal ( format ! ( "Unable to schedule python function call: {}" , err) )
86+ } ) ?;
8487
8588 tx. await ?
8689 }
@@ -193,7 +196,11 @@ impl PyRuntime {
193196 pub fn new ( js_channel : neon:: event:: Channel ) -> Self {
194197 let ( sender, mut receiver) = tokio:: sync:: mpsc:: channel :: < PyScheduledFun > ( 1024 ) ;
195198
199+ trace ! ( "New Python runtime" ) ;
200+
196201 std:: thread:: spawn ( || {
202+ trace ! ( "Initializing executor in a separate thread" ) ;
203+
197204 std:: thread:: spawn ( || {
198205 pyo3_asyncio:: tokio:: get_runtime ( )
199206 . block_on ( pyo3_asyncio:: tokio:: re_exports:: pending :: < ( ) > ( ) )
@@ -203,17 +210,18 @@ impl PyRuntime {
203210 pyo3_asyncio:: tokio:: run ( py, async move {
204211 loop {
205212 if let Some ( task) = receiver. recv ( ) . await {
206- trace ! ( "[py_runtime] task" ) ;
213+ trace ! ( "New task" ) ;
207214
208215 if let Err ( err) = Self :: process_task ( task, & js_channel) {
209- error ! ( "[py_runtime] Error while processing task: {:?}" , err)
216+ error ! ( "Error while processing python task: {:?}" , err)
210217 } ;
211218 }
212219 }
213220 } )
214221 } ) ;
215- if let Err ( err) = res {
216- error ! ( "Critical error while processing python calls: {}" , err)
222+ match res {
223+ Ok ( _) => trace ! ( "Python runtime loop was closed without error" ) ,
224+ Err ( err) => error ! ( "Critical error while processing python call: {}" , err) ,
217225 }
218226 } ) ;
219227
0 commit comments