Skip to content

Commit

Permalink
ARROW-17815: [Python] Warn, not error out, when SetSignalStopSource f…
Browse files Browse the repository at this point in the history
…ails (apache#14205)

In complex scenarios, the global signal-receiving StopSource may have already been created.

Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
pitrou authored and zagto committed Oct 7, 2022
1 parent 1aa26fe commit 47581c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/pyarrow/error.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,18 @@ cdef class SignalStopHandler:
_break_traceback_cycle_from_frame(sys._getframe(0))

self._stop_token = StopToken()

if not self._signals.empty():
self._stop_token.init(GetResultValue(
SetSignalStopSource()).token())
self._enabled = True
maybe_source = SetSignalStopSource()
if not maybe_source.ok():
# See ARROW-11841 / ARROW-17173: in complex interaction
# scenarios (such as R calling into Python), SetSignalStopSource()
# may have already activated a signal-receiving StopSource.
# Just warn instead of erroring out.
maybe_source.status().Warn()
else:
self._stop_token.init(deref(maybe_source).token())
self._enabled = True

def _init_signals(self):
if (signal_handlers_enabled and
Expand Down
2 changes: 2 additions & 0 deletions python/pyarrow/includes/common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
c_bool IsSerializationError()
c_bool IsCancelled()

void Warn()

cdef cppclass CStatusDetail "arrow::StatusDetail":
c_string ToString()

Expand Down

0 comments on commit 47581c2

Please sign in to comment.