Skip to content

Commit 1a1f67f

Browse files
vdrhtctacaswell
authored andcommitted
Change SIGPIPE to SIGCHLD
1 parent b384c82 commit 1a1f67f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/matplotlib/backends/qt_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _setDevicePixelRatio(obj, val):
197197

198198
@contextlib.contextmanager
199199
def _maybe_allow_interrupt(qapp):
200-
'''
200+
"""
201201
This manager allows to terminate a plot by sending a SIGINT. It is
202202
necessary because the running Qt backend prevents Python interpreter to
203203
run and process signals (i.e., to raise KeyboardInterrupt exception). To
@@ -218,7 +218,7 @@ def _maybe_allow_interrupt(qapp):
218218
We do this only if the old handler for SIGINT was not None, which means
219219
that a non-python handler was installed, i.e. in Julia, and not SIG_IGN
220220
which means we should ignore the interrupts.
221-
'''
221+
"""
222222
old_sigint_handler = signal.getsignal(signal.SIGINT)
223223
handler_args = None
224224
skip = False

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ def test_other_signal_before_sigint(qt_core, platform_simulate_ctrl_c,
9393
target, kwargs):
9494
plt.figure()
9595

96-
sigpipe_caught = False
96+
sigcld_caught = False
9797
def custom_sigpipe_handler(signum, frame):
98-
nonlocal sigpipe_caught
99-
sigpipe_caught = True
100-
signal.signal(signal.SIGPIPE, custom_sigpipe_handler)
98+
nonlocal sigcld_caught
99+
sigcld_caught = True
100+
signal.signal(signal.SIGCLD, custom_sigpipe_handler)
101101

102102
def fire_other_signal():
103-
os.kill(os.getpid(), signal.SIGPIPE)
103+
os.kill(os.getpid(), signal.SIGCLD)
104104

105105
def fire_sigint():
106106
platform_simulate_ctrl_c()
@@ -110,7 +110,7 @@ def fire_sigint():
110110
try:
111111
target(**kwargs)
112112
except KeyboardInterrupt as e:
113-
assert sigpipe_caught
113+
assert sigcld_caught
114114
else:
115115
assert False # KeyboardInterrupt must be raised
116116

0 commit comments

Comments
 (0)