nuno-faria commented on PR #1311:
URL: 
https://github.com/apache/datafusion-python/pull/1311#issuecomment-3582769759

   I was just looking into this and did a similar change just to check if it is 
executing in the main thread:
   
   ```rust
   tokio::select! {
       res = &mut fut => break Ok(res),
       _ = sleep(INTERVAL_CHECK_SIGNALS) => {
           Python::attach(|py| {
               let threading = PyModule::import(py, "threading")?;
               let get_ident = threading.getattr("get_ident")?;
               let thread_id: u64 = get_ident.call0()?.extract()?;
               println!("thread_id: {}", thread_id);
               let x = py.check_signals();
               println!("x: {:?}", x);
               x
           })?;
       }
   }
   ```
   
   Looking at the output, we can see that the thread ids match:
   
   ```
   sent signal to 8116 # printed "threading.main_thread().ident" in the python 
test
   thread_id: 8116
   x: Ok(())
   thread_id: 8116
   x: Ok(())
   thread_id: 8116
   x: Ok(())
   thread_id: 8116
   x: Ok(())
   thread_id: 8116
   ...
   ```
   
   I even delayed the signal sent by the `interrupt` function just in case but 
still wasn't able to trigger the exception:
   ```
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   sent signal to 14100
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   ...
   ```
   
   However, manually sending CTRL-C results in the exception being returned by 
the `check_signals`:
   ```
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Ok(())
   thread_id: 14100
   x: Err(PyErr { type: <class 'KeyboardInterrupt'>, value: 
KeyboardInterrupt(), traceback: None })
   PASSED
   ```
   
   I also checked if it was somehow an issue with `PyThreadState_SetAsyncExc`, 
but the test `test_collect_interrupted` works as expected. But in this test, 
the signal is also not being sent to the `check_signals`:
   
   ```
   python/tests/test_dataframe.py::test_collect_interrupted thread_id: 30632
   x: Ok(())
   thread_id: 30632
   x: Ok(())
   PASSED # no print of the interrupt
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to