This is an automated email from the ASF dual-hosted git repository.

HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git


The following commit(s) were added to refs/heads/master by this push:
     new f27e2333 [SPARK-61498][CONNECT][PYTHON] Raise the errors of the conf 
read of the origin of an expression, and end the wait of an execution at the 
second Ctrl-C while its interrupt hangs, in the Python client as PySpark does
f27e2333 is described below

commit f27e23330d8e2cfa706acf67148e482e3b4b2acd
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Thu Nov 12 12:22:04 2026 +0900

    [SPARK-61498][CONNECT][PYTHON] Raise the errors of the conf read of the 
origin of an expression, and end the wait of an execution at the second Ctrl-C 
while its interrupt hangs, in the Python client as PySpark does
    
    ### What changes were proposed in this pull request?
    
    [SPARK-61498](https://issues.apache.org/jira/browse/SPARK-61498): 
follow-ups of a post-hoc review of SPARK-61470 (#535), checked against PySpark 
4.3.0.
    
    - **The origin of an expression** (`crates/pyspark-rs/src/origin.rs`):
      - `with_origin` now returns the error of `is_debugging_enabled`, which 
reads `spark.python.sql.dataFrameDebugging.enabled` once per process.
      - The 79 functions that capture an origin (`F.col`, the Column methods, 
`groupBy`, ...) raise it, as PySpark's `_with_origin` does. Thirteen of them 
returned their value without a `PyResult`, and now return one.
      - A call site that cannot be read still leaves the expression without an 
origin, unless its error is not an `Exception`, such as a KeyboardInterrupt.
    - **`Column.__str__`** (`crates/pyspark-rs/src/column.rs`) captures no 
origin. PySpark's Column has no `__str__` of its own for `_with_origin` to 
wrap. Without this, `str(col)` would read the conf and could raise its error.
    - **The second Ctrl-C of an execution** 
(`crates/spark-connect-core/src/runtime.rs`, `watched`): once a signal has 
aborted the wait and so ended the execution, the wait cancels a running 
interrupt at once. It no longer awaits it.
    
    ### Why are the changes needed?
    
    - **A lost Ctrl-C.**
      - The origin capture dropped the errors of its conf read with 
`unwrap_or(None)`.
      - Against a server that does not answer, a Ctrl-C during the first 
`F.col("a")` of a session was lost. The call returned, built without an origin, 
and the next origin call (`F.col("b")`, `df.groupBy("id")`) waited again.
      - PySpark raises KeyboardInterrupt from `F.col` at the first Ctrl-C. In 
the review's probe, ours returned three times after three signals, and PySpark 
raised after one.
      - SPARK-61470 made that conf read interruptible, so its KeyboardInterrupt 
reached the drop.
      - The error of an unreachable server was dropped the same way, while 
PySpark raises it from `F.col`.
    - **A third Ctrl-C.**
      - During an execution, the first signal interrupts it and the second 
aborts the wait.
      - When the interrupt hung, or was retried after UNAVAILABLE, the aborted 
wait still awaited it, and only a third signal ended the call. PySpark stops at 
the second.
      - Against a mock server whose Interrupt hangs, ours raised 
KeyboardInterrupt from `collect()` after 3 signals and 5.2 s, and PySpark after 
2 signals and 3.0 s.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, as in PySpark:
    - A Ctrl-C during the first origin capture of a session raises 
KeyboardInterrupt.
    - The error of an unreachable server raises from the origin capture.
    - The second Ctrl-C ends an execution whose interrupt hangs.
    
    ### How was this patch tested?
    
    - Offline (`python/tests/test_dropin_offline.py`): new 
`test_sigint_raises_from_the_origin_capture_of_the_first_column_as_pyspark`, 
placed after 
`test_sigint_ends_a_call_to_an_unreachable_server_at_once_as_pyspark`.
      - In a subprocess against `sc://127.0.0.1:1`, a SIGINT after 1 s raises 
KeyboardInterrupt from the first `F.col`.
      - Without the change, `F.col` returns ("col returned after 1.2").
    - Rust (`runtime.rs`): new 
`test_a_second_signal_ends_the_wait_without_awaiting_a_hung_interrupt`.
      - The watch interrupts with a future that never ends, aborts at its 
second poll, and aborts again from its tenth, as a third signal would. The wait 
returns before that, and the interrupt is cancelled.
      - Without the change, it fails with "the wait needed a third signal".
    - Live, with the review's probes, against PySpark 4.3.0:
      - `F.col` against `sc://127.0.0.1:1` raises KeyboardInterrupt after one 
SIGINT (0.6 s).
      - Against a mock whose Interrupt hangs, and one whose Interrupt answers 
UNAVAILABLE, `collect()` raises KeyboardInterrupt after two SIGINTs, in 3.0 s, 
as PySpark does.
    - The SIGINT and origin tests of the offline suite (27) pass.
    - Checks:
      - the lib tests of both crates (829 passed);
      - the build of all tests, also with `wasm-udf` and `datafusion,polars`, 
without warnings;
      - `cargo fmt --all --check`, and clippy with no diagnostics on the 
changed lines;
      - `ruff check`;
      - a full trial on master before the merge.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 5.5
    
    This pull request and its description were written by Isaac.
    
    Closes #545 from HyukjinKwon/s19-ctrl-c-waits.
    
    Authored-by: Hyukjin Kwon <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 crates/pyspark-rs/src/column.rs          | 181 ++++++++++++++++---------------
 crates/pyspark-rs/src/dataframe.rs       |  16 +--
 crates/pyspark-rs/src/functions.rs       |   8 +-
 crates/pyspark-rs/src/group.rs           |   2 +-
 crates/pyspark-rs/src/origin.rs          |  17 ++-
 crates/pyspark-rs/src/stat.rs            |   2 +-
 crates/pyspark-rs/src/window.rs          |   2 +-
 crates/spark-connect-core/src/runtime.rs |  57 +++++++++-
 python/tests/test_dropin_offline.py      |  32 ++++++
 9 files changed, 206 insertions(+), 111 deletions(-)

diff --git a/crates/pyspark-rs/src/column.rs b/crates/pyspark-rs/src/column.rs
index 49f2fc7c..520a1c43 100644
--- a/crates/pyspark-rs/src/column.rs
+++ b/crates/pyspark-rs/src/column.rs
@@ -162,7 +162,7 @@ impl PyColumn {
         alias: Vec<String>,
         kwargs: Option<&Bound<'_, PyDict>>,
     ) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("alias");
+        let _origin = crate::origin::with_origin("alias")?;
         let mut metadata = None;
         if let Some(kwargs) = kwargs {
             let rest = kwargs.copy()?;
@@ -216,29 +216,29 @@ impl PyColumn {
         alias: Vec<String>,
         kwargs: Option<&Bound<'_, PyDict>>,
     ) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("name");
+        let _origin = crate::origin::with_origin("name")?;
         self.alias(py, alias, kwargs)
     }
 
     /// Apply a transformation function to this column. Mirrors 
`Column.transform(f)`,
     /// which is simply `f(self)`.
     fn transform<'py>(slf: Bound<'py, Self>, f: Bound<'py, PyAny>) -> 
PyResult<Bound<'py, PyAny>> {
-        let _origin = crate::origin::with_origin("transform");
+        let _origin = crate::origin::with_origin("transform")?;
         f.call1((slf,))
     }
 
     /// Mark this column as an outer reference (for correlated subqueries / 
lateral
     /// joins). Mirrors `Column.outer()`, which returns the same expression — 
outer
     /// resolution is performed server-side via the plan id.
-    fn outer(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("outer");
-        PyColumn::new(self.column.clone())
+    fn outer(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("outer")?;
+        Ok(PyColumn::new(self.column.clone()))
     }
 
     /// Cast to a different type. Accepts a `DataType` or a DDL type string,
     /// matching `pyspark.sql.Column.cast`.
     fn cast(&self, dataType: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("cast");
+        let _origin = crate::origin::with_origin("cast")?;
         // As PySpark's, of a DataType or a str.
         if !(dataType.is_instance_of::<pyo3::types::PyString>()
             || dataType.is_instance_of::<crate::types::PyDataType>())
@@ -257,7 +257,7 @@ impl PyColumn {
 
     /// Alias for `cast` (pyspark `Column.astype`).
     fn astype(&self, dataType: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("astype");
+        let _origin = crate::origin::with_origin("astype")?;
         self.cast(dataType)
     }
 
@@ -265,7 +265,7 @@ impl PyColumn {
     /// Mirrors `pyspark.sql.Column.try_cast`.
     #[pyo3(name = "try_cast")]
     fn try_cast(&self, dataType: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("try_cast");
+        let _origin = crate::origin::with_origin("try_cast")?;
         // As PySpark's: a DataType or a str, else NOT_EXPECTED_TYPE.
         if !dataType.is_instance_of::<crate::types::PyDataType>()
             && !dataType.is_instance_of::<pyo3::types::PyString>()
@@ -288,7 +288,7 @@ impl PyColumn {
     /// FutureWarning for a Column as the key.
     #[pyo3(name = "getItem")]
     fn get_item(&self, key: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("getItem");
+        let _origin = crate::origin::with_origin("getItem")?;
         if key.extract::<PyRef<'_, PyColumn>>().is_ok() {
             let py = key.py();
             let category = py.get_type::<pyo3::exceptions::PyFutureWarning>();
@@ -310,21 +310,21 @@ impl PyColumn {
 
     /// Check if NULL.
     #[pyo3(name = "isNull")]
-    fn is_null(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("isNull");
-        PyColumn::new(self.column.clone().is_null())
+    fn is_null(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("isNull")?;
+        Ok(PyColumn::new(self.column.clone().is_null()))
     }
 
     /// Check if NOT NULL.
     #[pyo3(name = "isNotNull")]
-    fn is_not_null(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("isNotNull");
-        PyColumn::new(self.column.clone().is_not_null())
+    fn is_not_null(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("isNotNull")?;
+        Ok(PyColumn::new(self.column.clone().is_not_null()))
     }
 
     /// Substring extraction (start and length as columns).
     fn substr(&self, startPos: &Bound<'_, PyAny>, length: &Bound<'_, PyAny>) 
-> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("substr");
+        let _origin = crate::origin::with_origin("substr")?;
         // As PySpark: the arguments, as values of an Enum, must be of one 
type, a Column or
         // an int.
         let py = startPos.py();
@@ -370,77 +370,77 @@ impl PyColumn {
 
     /// Pattern matching with LIKE, of any value, as PySpark's 
`_bin_op("like", ...)`.
     fn like(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("like");
+        let _origin = crate::origin::with_origin("like")?;
         binary_function("like", &self.column, other)
     }
 
     /// Pattern matching with RLIKE (regex).
     fn rlike(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("rlike");
+        let _origin = crate::origin::with_origin("rlike")?;
         binary_function("rlike", &self.column, other)
     }
 
     /// Check if contains another column value.
     fn contains(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("contains");
+        let _origin = crate::origin::with_origin("contains")?;
         let other_col = operand_column(other)?;
         Ok(PyColumn::new(self.column.clone().contains(other_col)))
     }
 
     /// Check if starts with another column value.
     fn startswith(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("startswith");
+        let _origin = crate::origin::with_origin("startswith")?;
         let other_col = operand_column(other)?;
         Ok(PyColumn::new(self.column.clone().startswith(other_col)))
     }
 
     /// Check if ends with another column value.
     fn endswith(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("endswith");
+        let _origin = crate::origin::with_origin("endswith")?;
         let other_col = operand_column(other)?;
         Ok(PyColumn::new(self.column.clone().endswith(other_col)))
     }
 
     /// Ascending sort.
-    fn asc(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("asc");
-        PyColumn::new(self.column.clone().asc())
+    fn asc(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("asc")?;
+        Ok(PyColumn::new(self.column.clone().asc()))
     }
 
     /// Ascending sort with nulls first.
-    fn asc_nulls_first(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("asc_nulls_first");
-        PyColumn::new(self.column.clone().asc_nulls_first())
+    fn asc_nulls_first(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("asc_nulls_first")?;
+        Ok(PyColumn::new(self.column.clone().asc_nulls_first()))
     }
 
     /// Ascending sort with nulls last.
-    fn asc_nulls_last(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("asc_nulls_last");
-        PyColumn::new(self.column.clone().asc_nulls_last())
+    fn asc_nulls_last(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("asc_nulls_last")?;
+        Ok(PyColumn::new(self.column.clone().asc_nulls_last()))
     }
 
     /// Descending sort.
-    fn desc(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("desc");
-        PyColumn::new(self.column.clone().desc())
+    fn desc(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("desc")?;
+        Ok(PyColumn::new(self.column.clone().desc()))
     }
 
     /// Descending sort with nulls first.
-    fn desc_nulls_first(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("desc_nulls_first");
-        PyColumn::new(self.column.clone().desc_nulls_first())
+    fn desc_nulls_first(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("desc_nulls_first")?;
+        Ok(PyColumn::new(self.column.clone().desc_nulls_first()))
     }
 
     /// Descending sort with nulls last.
-    fn desc_nulls_last(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("desc_nulls_last");
-        PyColumn::new(self.column.clone().desc_nulls_last())
+    fn desc_nulls_last(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("desc_nulls_last")?;
+        Ok(PyColumn::new(self.column.clone().desc_nulls_last()))
     }
 
     /// A branch more of a CASE WHEN. Mirrors `Column.when`: the condition is 
a Column, and
     /// the column a `when()` without `otherwise()` (`INVALID_WHEN_USAGE`).
     fn when(&self, condition: &Bound<'_, PyAny>, value: &Bound<'_, PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("when");
+        let _origin = crate::origin::with_origin("when")?;
         let py = condition.py();
         let Ok(condition) = condition.extract::<PyRef<'_, PyColumn>>() else {
             let arg_type = condition.get_type().name()?.to_string();
@@ -475,7 +475,7 @@ impl PyColumn {
     /// The value of a CASE WHEN when no branch holds. Mirrors 
`Column.otherwise`, which
     /// raises PySparkTypeError for a column that is not a `when()`, or one 
that has one.
     fn otherwise(&self, value: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("otherwise");
+        let _origin = crate::origin::with_origin("otherwise")?;
         let message = match self.column.expression().node() {
             ExpressionNode::CaseWhen(case_when) if 
case_when.else_expr.is_none() => None,
             ExpressionNode::CaseWhen(_) => Some(
@@ -498,7 +498,7 @@ impl PyColumn {
     /// Get item by key/index, or a slice as `substr(start, stop)`. Mirrors
     /// `Column.__getitem__`.
     fn __getitem__(&self, key: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__getitem__");
+        let _origin = crate::origin::with_origin("__getitem__")?;
         if key.is_instance_of::<pyo3::types::PySlice>() {
             if !key.getattr("step")?.is_none() {
                 return Err(raise_pyspark(
@@ -518,7 +518,7 @@ impl PyColumn {
     /// `col["name"]`. Mirrors `Column.__getattr__`, which raises for `_jc` 
and for a name
     /// that starts with `__`.
     fn __getattr__(&self, py: Python<'_>, item: &str) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__getattr__");
+        let _origin = crate::origin::with_origin("__getattr__")?;
         if item == "_jc" {
             return Err(raise_pyspark(
                 py,
@@ -540,42 +540,42 @@ impl PyColumn {
 
     /// Equality (==) - returns a Column condition
     fn __eq__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__eq__");
+        let _origin = crate::origin::with_origin("__eq__")?;
         let other_col = equality_operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().eq(other_col)))
     }
 
     /// Inequality (!=) - returns a Column condition
     fn __ne__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__ne__");
+        let _origin = crate::origin::with_origin("__ne__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().ne(other_col)))
     }
 
     /// Greater than (>) - returns a Column condition
     fn __gt__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__gt__");
+        let _origin = crate::origin::with_origin("__gt__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().gt(other_col)))
     }
 
     /// Less than (<) - returns a Column condition
     fn __lt__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__lt__");
+        let _origin = crate::origin::with_origin("__lt__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().lt(other_col)))
     }
 
     /// Greater than or equal (>=) - returns a Column condition
     fn __ge__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__ge__");
+        let _origin = crate::origin::with_origin("__ge__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().ge(other_col)))
     }
 
     /// Less than or equal (<=) - returns a Column condition
     fn __le__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__le__");
+        let _origin = crate::origin::with_origin("__le__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().le(other_col)))
     }
@@ -583,49 +583,49 @@ impl PyColumn {
     // Arithmetic operators
     /// Addition (+)
     fn __add__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__add__");
+        let _origin = crate::origin::with_origin("__add__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().add(other_col)))
     }
 
     /// Right addition (for reverse operations)
     fn __radd__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__radd__");
+        let _origin = crate::origin::with_origin("__radd__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(other_col.add(self.column.clone())))
     }
 
     /// Subtraction (-)
     fn __sub__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__sub__");
+        let _origin = crate::origin::with_origin("__sub__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().sub(other_col)))
     }
 
     /// Right subtraction (for reverse operations)
     fn __rsub__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__rsub__");
+        let _origin = crate::origin::with_origin("__rsub__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(other_col.sub(self.column.clone())))
     }
 
     /// Multiplication (*)
     fn __mul__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__mul__");
+        let _origin = crate::origin::with_origin("__mul__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().mul(other_col)))
     }
 
     /// Right multiplication (for reverse operations)
     fn __rmul__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__rmul__");
+        let _origin = crate::origin::with_origin("__rmul__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(other_col.mul(self.column.clone())))
     }
 
     /// Division (/)
     fn __truediv__(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__truediv__");
+        let _origin = crate::origin::with_origin("__truediv__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().div(other_col)))
     }
@@ -633,14 +633,14 @@ impl PyColumn {
     /// Division (/), of the name of Python 2, as PySpark's Column has it, 
which pandas-on-Spark
     /// calls: as `__truediv__`.
     fn __div__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__div__");
+        let _origin = crate::origin::with_origin("__div__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().div(other_col)))
     }
 
     /// Modulo (%)
     fn __mod__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__mod__");
+        let _origin = crate::origin::with_origin("__mod__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().modulo(other_col)))
     }
@@ -648,34 +648,34 @@ impl PyColumn {
     // Bitwise operators (logical in Spark context)
     /// Bitwise AND (&) - logical AND in Spark
     fn __and__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__and__");
+        let _origin = crate::origin::with_origin("__and__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().and(other_col)))
     }
 
     /// Bitwise OR (|) - logical OR in Spark
     fn __or__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__or__");
+        let _origin = crate::origin::with_origin("__or__")?;
         let other_col = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().or(other_col)))
     }
 
     /// Bitwise NOT (~) - logical NOT in Spark
-    fn __invert__(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("__invert__");
-        PyColumn::new(self.column.clone().not())
+    fn __invert__(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("__invert__")?;
+        Ok(PyColumn::new(self.column.clone().not()))
     }
 
     /// Negation (-)
-    fn __neg__(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("__neg__");
-        PyColumn::new(self.column.clone().neg())
+    fn __neg__(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("__neg__")?;
+        Ok(PyColumn::new(self.column.clone().neg()))
     }
 
     /// Get field by name (for struct/nested types).
     #[pyo3(name = "getField")]
     fn get_field(&self, name: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("getField");
+        let _origin = crate::origin::with_origin("getField")?;
         // As PySpark's, `self[name]`, with a FutureWarning for a Column.
         if name.extract::<PyRef<'_, PyColumn>>().is_ok() {
             let py = name.py();
@@ -697,7 +697,7 @@ impl PyColumn {
 
     /// Apply a window function over a window specification.
     fn over(&self, window: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("over");
+        let _origin = crate::origin::with_origin("over")?;
         let Ok(window) = window.extract::<PyRef<'_, 
crate::window::PyWindowSpec>>() else {
             return Err(not_expected_type(window, "window", "WindowSpec"));
         };
@@ -827,35 +827,36 @@ impl PyColumn {
         )))
     }
 
+    /// As PySpark's Column, which has no `__str__` of its own for 
`_with_origin` to wrap: no
+    /// origin, so no read of the debugging conf.
     fn __str__(&self) -> String {
-        let _origin = crate::origin::with_origin("__str__");
         self.__repr__()
     }
 
     // --- reverse arithmetic/logical dunders (operand order swapped) ---
     fn __rtruediv__(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__rtruediv__");
+        let _origin = crate::origin::with_origin("__rtruediv__")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(o.div(self.column.clone())))
     }
     /// Reverse division, of the name of Python 2, as PySpark's Column has it: 
as `__rtruediv__`.
     fn __rdiv__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__rdiv__");
+        let _origin = crate::origin::with_origin("__rdiv__")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(o.div(self.column.clone())))
     }
     fn __rmod__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__rmod__");
+        let _origin = crate::origin::with_origin("__rmod__")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(o.modulo(self.column.clone())))
     }
     fn __rand__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("__rand__");
+        let _origin = crate::origin::with_origin("__rand__")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().and(o)))
     }
     fn __ror__(&self, py: Python<'_>, other: Py<PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__ror__");
+        let _origin = crate::origin::with_origin("__ror__")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().or(o)))
     }
@@ -863,7 +864,7 @@ impl PyColumn {
     /// `col ** other`. Mirrors `Column.__pow__` = `power(self, other)`. 
PySpark's takes no
     /// modulo, so the ternary `pow(col, other, modulo)` raises the TypeError 
of its call.
     fn __pow__(&self, py: Python<'_>, other: Py<PyAny>, modulo: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("__pow__");
+        let _origin = crate::origin::with_origin("__pow__")?;
         if !modulo.is_none(py) {
             return Err(pyo3::exceptions::PyTypeError::new_err(
                 "Column.__pow__() takes 2 positional arguments but 3 were 
given",
@@ -880,7 +881,7 @@ impl PyColumn {
     /// `pow(other, col, modulo)` is not implemented, so that Python raises 
its TypeError of the
     /// operand types, as for PySpark's, which takes no modulo.
     fn __rpow__(&self, py: Python<'_>, other: Py<PyAny>, modulo: Py<PyAny>) -> 
PyResult<Py<PyAny>> {
-        let _origin = crate::origin::with_origin("__rpow__");
+        let _origin = crate::origin::with_origin("__rpow__")?;
         if !modulo.is_none(py) {
             return Ok(py.NotImplemented());
         }
@@ -894,7 +895,7 @@ impl PyColumn {
 
     /// `x in col` is not supported. Mirrors `Column.__contains__`.
     fn __contains__(&self, py: Python<'_>, _item: Py<PyAny>) -> PyResult<()> {
-        let _origin = crate::origin::with_origin("__contains__");
+        let _origin = crate::origin::with_origin("__contains__")?;
         Err(raise_pyspark(
             py,
             "PySparkValueError",
@@ -941,47 +942,47 @@ impl PyColumn {
         lowerBound: Py<PyAny>,
         upperBound: Py<PyAny>,
     ) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("between");
+        let _origin = crate::origin::with_origin("between")?;
         let l = operand_column(lowerBound.bind(py))?;
         let u = operand_column(upperBound.bind(py))?;
         Ok(PyColumn::new(self.column.clone().between(l, u)))
     }
     #[pyo3(name = "bitwiseAND")]
     fn bitwise_and(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("bitwiseAND");
+        let _origin = crate::origin::with_origin("bitwiseAND")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().bitwise_and(o)))
     }
     #[pyo3(name = "bitwiseOR")]
     fn bitwise_or(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("bitwiseOR");
+        let _origin = crate::origin::with_origin("bitwiseOR")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().bitwise_or(o)))
     }
     #[pyo3(name = "bitwiseXOR")]
     fn bitwise_xor(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("bitwiseXOR");
+        let _origin = crate::origin::with_origin("bitwiseXOR")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().bitwise_xor(o)))
     }
     fn ilike(&self, other: &Bound<'_, PyAny>) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("ilike");
+        let _origin = crate::origin::with_origin("ilike")?;
         binary_function("ilike", &self.column, other)
     }
     #[pyo3(name = "isNaN")]
-    fn is_nan(&self) -> PyColumn {
-        let _origin = crate::origin::with_origin("isNaN");
-        PyColumn::new(self.column.clone().is_nan())
+    fn is_nan(&self) -> PyResult<PyColumn> {
+        let _origin = crate::origin::with_origin("isNaN")?;
+        Ok(PyColumn::new(self.column.clone().is_nan()))
     }
     #[pyo3(name = "eqNullSafe")]
     fn eq_null_safe(&self, py: Python<'_>, other: Py<PyAny>) -> 
PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("eqNullSafe");
+        let _origin = crate::origin::with_origin("eqNullSafe")?;
         let o = operand_column(other.bind(py))?;
         Ok(PyColumn::new(self.column.clone().eq_null_safe(o)))
     }
     #[pyo3(signature = (*cols))]
     fn isin(&self, py: Python<'_>, cols: Vec<Py<PyAny>>) -> PyResult<PyColumn> 
{
-        let _origin = crate::origin::with_origin("isin");
+        let _origin = crate::origin::with_origin("isin")?;
         // As pyspark's, a single DataFrame makes an IN subquery of it.
         if let [only] = cols.as_slice() {
             if let Ok(df) = only
@@ -1021,7 +1022,7 @@ impl PyColumn {
         fieldName: &Bound<'_, PyAny>,
         col: &Bound<'_, PyAny>,
     ) -> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("withField");
+        let _origin = crate::origin::with_origin("withField")?;
         // As PySpark's, of a str and a Column.
         if !fieldName.is_instance_of::<pyo3::types::PyString>() {
             return Err(not_expected_type(fieldName, "fieldName", "str"));
@@ -1038,7 +1039,7 @@ impl PyColumn {
     }
     #[pyo3(name = "dropFields", signature = (*fieldNames))]
     fn drop_fields(&self, py: Python<'_>, fieldNames: Vec<Bound<'_, PyAny>>) 
-> PyResult<PyColumn> {
-        let _origin = crate::origin::with_origin("dropFields");
+        let _origin = crate::origin::with_origin("dropFields")?;
         // As PySpark's, of strings, at least one.
         let mut names = Vec::with_capacity(fieldNames.len());
         for name in &fieldNames {
diff --git a/crates/pyspark-rs/src/dataframe.rs 
b/crates/pyspark-rs/src/dataframe.rs
index b2b412fb..1745b241 100644
--- a/crates/pyspark-rs/src/dataframe.rs
+++ b/crates/pyspark-rs/src/dataframe.rs
@@ -229,7 +229,7 @@ impl PyDataFrame {
             .as_any()
             .get_item(index)?
             .extract()?;
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         Ok(spark_connect::functions::col(&name))
     }
 
@@ -261,7 +261,7 @@ impl PyDataFrame {
                 }
                 if c.is_instance_of::<PyString>() {
                     // As PySpark's `F._to_col`, by `col`, of its origin.
-                    let _origin = crate::origin::with_origin("col");
+                    let _origin = crate::origin::with_origin("col")?;
                     return 
Ok(spark_connect::functions::col(&c.extract::<String>()?));
                 }
                 if c.is_instance_of::<PyInt>() && 
!c.is_instance_of::<PyBool>() {
@@ -320,7 +320,7 @@ impl PyDataFrame {
                 column.column.clone()
             } else if c.is_instance_of::<PyString>() {
                 // As PySpark's `F._to_col`, by `col`, of its origin.
-                let _origin = crate::origin::with_origin("col");
+                let _origin = crate::origin::with_origin("col")?;
                 spark_connect::functions::col(&c.extract::<String>()?)
             } else {
                 return Err(not_expected_type(&c, "col", "Column, int or str"));
@@ -441,7 +441,7 @@ pub(crate) fn to_columns_as_given(
             // Try as string (column name)
             if let Ok(name) = arg.extract::<String>() {
                 // As PySpark's `F._to_col`, by `col`, of its origin.
-                let _origin = crate::origin::with_origin("col");
+                let _origin = crate::origin::with_origin("col")?;
                 cols.push(spark_connect::functions::col(&name));
             } else {
                 // As PySpark's `_to_cols`.
@@ -1140,7 +1140,7 @@ impl PyDataFrame {
             Some(c) => Some(if let Ok(column) = c.extract::<PyRef<'_, 
PyColumn>>() {
                 column.column.clone()
             } else if c.is_instance_of::<pyo3::types::PyString>() {
-                let _origin = crate::origin::with_origin("col");
+                let _origin = crate::origin::with_origin("col")?;
                 spark_connect::functions::col(&c.extract::<String>()?)
             } else {
                 return Err(not_expected_type(c, "col", "Column or str"));
@@ -1225,7 +1225,7 @@ impl PyDataFrame {
             c.borrow().column.clone()
         } else if let Ok(name) = partitionIdCol.extract::<String>() {
             // As PySpark's `F._to_col`, by `col`, of its origin.
-            let _origin = crate::origin::with_origin("col");
+            let _origin = crate::origin::with_origin("col")?;
             spark_connect::functions::col(&name)
         } else {
             return Err(PyErr::new::<pyo3::exceptions::PyTypeError, _>(
@@ -2771,7 +2771,7 @@ impl PyDataFrame {
             ));
         };
         // As PySpark's `F.col(self.columns[item])`, of the origin of `col`.
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         PyColumn::new(spark_connect::functions::col(&name)).into_py_any(py)
     }
 
@@ -3259,7 +3259,7 @@ pub(crate) fn column_or_name(col: &Bound<'_, PyAny>) -> 
PyResult<spark_connect::
     }
     if col.is_instance_of::<pyo3::types::PyString>() {
         // As PySpark's `F._to_col`, by `col`, of its origin.
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         return Ok(spark_connect::functions::col(&col.extract::<String>()?));
     }
     Err(not_expected_type(col, "col", "Column or str"))
diff --git a/crates/pyspark-rs/src/functions.rs 
b/crates/pyspark-rs/src/functions.rs
index 0931d2b9..f57b7830 100644
--- a/crates/pyspark-rs/src/functions.rs
+++ b/crates/pyspark-rs/src/functions.rs
@@ -855,10 +855,10 @@ fn scalar_literal(obj: &Bound<'_, PyAny>) -> 
PyResult<Option<LiteralExpression>>
 }
 
 #[pyfunction]
-fn pyfunc_col(name: &str) -> PyColumn {
+fn pyfunc_col(name: &str) -> PyResult<PyColumn> {
     // As PySpark's `col`, of `_with_origin`.
-    let _origin = crate::origin::with_origin("col");
-    PyColumn::new(spark_funcs::col(name))
+    let _origin = crate::origin::with_origin("col")?;
+    Ok(PyColumn::new(spark_funcs::col(name)))
 }
 
 #[pyfunction]
@@ -893,7 +893,7 @@ fn pyfunc_count(col: &Bound<'_, PyAny>) -> 
PyResult<PyColumn> {
         }
     } else if col.is_instance_of::<pyo3::types::PyString>() {
         // As PySpark's `_to_col`, by `col`, of its origin.
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         spark_funcs::col(&col.extract::<String>()?)
     } else {
         let type_name = col.get_type().name()?.to_string();
diff --git a/crates/pyspark-rs/src/group.rs b/crates/pyspark-rs/src/group.rs
index 5e258f3c..5349c962 100644
--- a/crates/pyspark-rs/src/group.rs
+++ b/crates/pyspark-rs/src/group.rs
@@ -64,7 +64,7 @@ pub(crate) fn dict_aggregates(
             return Err(pyo3::exceptions::PyAssertionError::new_err(()));
         };
         // As PySpark's `agg` of a dict, by `col`, of its origin.
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         let c = spark_connect::functions::col(&column);
         // Build func(col) as an unresolved function resolved server-side, so 
aggregate names
         // (max/min/sum/avg/count/...) all work regardless of whether they are 
in the generated
diff --git a/crates/pyspark-rs/src/origin.rs b/crates/pyspark-rs/src/origin.rs
index 786ae809..c17c3b96 100644
--- a/crates/pyspark-rs/src/origin.rs
+++ b/crates/pyspark-rs/src/origin.rs
@@ -21,9 +21,13 @@ static IPYTHON_IMPORTS_TRIED: AtomicBool = 
AtomicBool::new(false);
 /// debugging is enabled. As PySpark's `_with_origin`, with the functions of
 /// `pyspark.errors.utils` that it calls: `is_debugging_enabled`, which reads
 /// `spark.python.sql.dataFrameDebugging.enabled` once, and 
`_capture_call_site`, which
-/// `call_site` gives without importing a module per call. An origin that 
cannot be read is
-/// not set, as an expression is the same without one.
-pub(crate) fn with_origin(fragment: &str) -> Option<OriginGuard> {
+/// `call_site` gives without importing a module per call.
+///
+/// As `_with_origin`, the error of `is_debugging_enabled` is raised by the 
API function: the
+/// KeyboardInterrupt that ends its wait for the server, or the error of a 
server that cannot be
+/// reached. A call site that cannot be read leaves the expression without an 
origin, as it is
+/// the same without one, unless its error is not an `Exception`, as a 
KeyboardInterrupt.
+pub(crate) fn with_origin(fragment: &str) -> PyResult<Option<OriginGuard>> {
     Python::attach(|py| -> PyResult<Option<OriginGuard>> {
         let utils = UTILS
             .get_or_try_init(py, || 
py.import("pyspark.errors.utils").map(Bound::unbind))?
@@ -31,13 +35,16 @@ pub(crate) fn with_origin(fragment: &str) -> 
Option<OriginGuard> {
         if !utils.call_method0("is_debugging_enabled")?.is_truthy()? {
             return Ok(None);
         }
-        let call_site = call_site(py, 1)?;
+        let call_site = match call_site(py, 1) {
+            Ok(call_site) => call_site,
+            Err(err) if 
err.is_instance_of::<pyo3::exceptions::PyException>(py) => return Ok(None),
+            Err(err) => return Err(err),
+        };
         Ok(Some(set_current(Origin {
             fragment: fragment.to_string(),
             call_site,
         })))
     })
-    .unwrap_or(None)
 }
 
 /// The call site of the first `depth` frames of user code, as 
`_capture_call_site(depth)` of
diff --git a/crates/pyspark-rs/src/stat.rs b/crates/pyspark-rs/src/stat.rs
index 39433527..44a066eb 100644
--- a/crates/pyspark-rs/src/stat.rs
+++ b/crates/pyspark-rs/src/stat.rs
@@ -127,7 +127,7 @@ pub(crate) fn sample_by_arguments(
         |obj: &Bound<'_, PyAny>| -> PyResult<String> { 
Ok(obj.get_type().name()?.to_string()) };
     let col = if let Ok(name) = col.cast::<PyString>() {
         // As PySpark's `F._to_col`, by `col`, of its origin.
-        let _origin = crate::origin::with_origin("col");
+        let _origin = crate::origin::with_origin("col")?;
         spark_connect::functions::col(&name.to_cow()?)
     } else if let Ok(column) = col.extract::<PyRef<'_, PyColumn>>() {
         column.column.clone()
diff --git a/crates/pyspark-rs/src/window.rs b/crates/pyspark-rs/src/window.rs
index 5b797f9b..6e0dbe37 100644
--- a/crates/pyspark-rs/src/window.rs
+++ b/crates/pyspark-rs/src/window.rs
@@ -28,7 +28,7 @@ pub(crate) fn window_columns(
             }
             if c.is_instance_of::<pyo3::types::PyString>() {
                 // As PySpark's `F._to_col`, by `col`, of its origin.
-                let _origin = crate::origin::with_origin("col");
+                let _origin = crate::origin::with_origin("col")?;
                 return 
Ok(spark_connect::functions::col(&c.extract::<String>()?));
             }
             let type_name = c.get_type().name()?.to_string();
diff --git a/crates/spark-connect-core/src/runtime.rs 
b/crates/spark-connect-core/src/runtime.rs
index 678bfd3d..6a5c7ebc 100644
--- a/crates/spark-connect-core/src/runtime.rs
+++ b/crates/spark-connect-core/src/runtime.rs
@@ -236,12 +236,20 @@ async fn watched<F: Future>(
     tokio::pin!(f);
     let mut ticks = tokio::time::interval(POLL_INTERVAL);
     let mut interrupt: Option<tokio::task::JoinHandle<()>> = None;
+    // Whether `watch` aborted the wait, which a second signal after an 
interrupt does.
+    let mut aborted = false;
     loop {
         tokio::select! {
             output = &mut f => {
                 // The interrupt is awaited, and a second signal, polled 
meanwhile, ends the wait
-                // of it: the interrupt is then cancelled.
+                // of it: the interrupt is then cancelled. When that signal 
already aborted the
+                // wait, which ended `f`, the interrupt is cancelled at once, 
as PySpark stops at
+                // the second signal while an interrupt hangs or is retried.
                 if let Some(mut interrupt) = interrupt {
+                    if aborted {
+                        interrupt.abort();
+                        return output;
+                    }
                     loop {
                         tokio::select! {
                             _ = &mut interrupt => break,
@@ -267,6 +275,7 @@ async fn watched<F: Future>(
                 }
                 Watch::Abort => {
                     abort.send_replace(ABORT_ALL);
+                    aborted = true;
                 }
             },
         }
@@ -498,6 +507,52 @@ mod tests {
         assert!(interrupted.load(std::sync::atomic::Ordering::SeqCst));
     }
 
+    #[test]
+    fn test_a_second_signal_ends_the_wait_without_awaiting_a_hung_interrupt() {
+        // The first signal interrupts, and the interrupt never ends, as 
against a server that
+        // does not answer it. The second aborts the wait, which ends its 
future, and the wait
+        // returns at once, cancelling the interrupt, without the third signal 
that comes later.
+        use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
+        struct Dropped(Arc<AtomicBool>);
+        impl Drop for Dropped {
+            fn drop(&mut self) {
+                self.0.store(true, Ordering::SeqCst);
+            }
+        }
+        let polls = Arc::new(AtomicUsize::new(0));
+        let cancelled = Arc::new(AtomicBool::new(false));
+        let (counter, flag) = (Arc::clone(&polls), Arc::clone(&cancelled));
+        let watch: Arc<WaitWatch> =
+            Arc::new(move || match counter.fetch_add(1, Ordering::SeqCst) {
+                0 => {
+                    let dropped = Dropped(Arc::clone(&flag));
+                    Watch::Interrupt(Box::pin(async move {
+                        let _dropped = dropped;
+                        std::future::pending::<()>().await
+                    }))
+                }
+                1 => Watch::Abort,
+                n if n >= 10 => Watch::Abort,
+                _ => Watch::Continue,
+            });
+        let output = with_wait_watch(watch, || {
+            block_on(until_abort(ABORT_ALL, std::future::pending::<u8>()))
+        });
+        assert_eq!(output, None);
+        assert!(
+            polls.load(Ordering::SeqCst) < 10,
+            "the wait needed a third signal"
+        );
+        let deadline = std::time::Instant::now() + 
std::time::Duration::from_secs(5);
+        while !cancelled.load(Ordering::SeqCst) && std::time::Instant::now() < 
deadline {
+            std::thread::sleep(std::time::Duration::from_millis(10));
+        }
+        assert!(
+            cancelled.load(Ordering::SeqCst),
+            "the interrupt was not cancelled"
+        );
+    }
+
     #[test]
     fn 
test_an_abortable_wait_ends_when_its_watch_aborts_and_another_keeps_waiting() {
         // A watch that aborts ends an abortable wait at once, without the 
output of its future.
diff --git a/python/tests/test_dropin_offline.py 
b/python/tests/test_dropin_offline.py
index df082e92..82317535 100644
--- a/python/tests/test_dropin_offline.py
+++ b/python/tests/test_dropin_offline.py
@@ -19646,6 +19646,38 @@ except KeyboardInterrupt:
     assert 2.0 <= float(lines[-1].rsplit(" ", 1)[1]) < 4.5, result.stdout
 
 
+def 
test_sigint_raises_from_the_origin_capture_of_the_first_column_as_pyspark():
+    # As PySpark's _with_origin, which lets the error of is_debugging_enabled 
raise: the first
+    # F.col of a session reads spark.python.sql.dataFrameDebugging.enabled, 
which no server
+    # answers here, and a signal during its retries raises KeyboardInterrupt 
from F.col.
+    import subprocess
+    import sys
+
+    code = """
+import os, signal, threading, time
+from pyspark.sql import SparkSession, functions as F
+spark = SparkSession.builder.remote("sc://127.0.0.1:1").getOrCreate()
+threading.Timer(1.0, lambda: os.kill(os.getpid(), signal.SIGINT)).start()
+started = time.monotonic()
+try:
+    F.col("a")
+    print("col returned after", round(time.monotonic() - started, 1))
+except KeyboardInterrupt:
+    print("interrupted after", round(time.monotonic() - started, 1))
+"""
+    result = subprocess.run(
+        [sys.executable, "-c", code],
+        env=dict(os.environ, TZ="UTC"),
+        capture_output=True,
+        text=True,
+        timeout=60,
+    )
+    assert result.returncode == 0, result.stderr
+    lines = result.stdout.splitlines()
+    assert lines[-1].startswith("interrupted after "), result.stdout
+    assert 1.0 <= float(lines[-1].rsplit(" ", 1)[1]) < 3.5, result.stdout
+
+
 def test_connect_registry_sends_auto_cdc_define_flow(mock_connect):
     from pyspark import pipelines as dp
     from pyspark.pipelines.graph_element_registry import 
graph_element_registration_context


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

Reply via email to