Skip to content

Commit 6d2ea09

Browse files
committed
Change SIGPIPE to SIGCHLD
1 parent 4f2ed3a commit 6d2ea09

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
@@ -241,7 +241,7 @@ def _setDevicePixelRatio(obj, val):
241241

242242
@contextlib.contextmanager
243243
def _maybe_allow_interrupt(qapp):
244-
'''
244+
"""
245245
This manager allows to terminate a plot by sending a SIGINT. It is
246246
necessary because the running Qt backend prevents Python interpreter to
247247
run and process signals (i.e., to raise KeyboardInterrupt exception). To
@@ -262,7 +262,7 @@ def _maybe_allow_interrupt(qapp):
262262
We do this only if the old handler for SIGINT was not None, which means
263263
that a non-python handler was installed, i.e. in Julia, and not SIG_IGN
264264
which means we should ignore the interrupts.
265-
'''
265+
"""
266266
old_sigint_handler = signal.getsignal(signal.SIGINT)
267267
handler_args = None
268268
skip = False

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def test_other_signal_before_sigint(qt_core, platform_simulate_ctrl_c,
100100
target, kwargs):
101101
plt.figure()
102102

103-
sigpipe_caught = False
103+
sigcld_caught = False
104104
def custom_sigpipe_handler(signum, frame):
105-
nonlocal sigpipe_caught
106-
sigpipe_caught = True
107-
signal.signal(signal.SIGPIPE, custom_sigpipe_handler)
105+
nonlocal sigcld_caught
106+
sigcld_caught = True
107+
signal.signal(signal.SIGCLD, custom_sigpipe_handler)
108108

109109
def fire_other_signal():
110-
os.kill(os.getpid(), signal.SIGPIPE)
110+
os.kill(os.getpid(), signal.SIGCLD)
111111

112112
def fire_sigint():
113113
platform_simulate_ctrl_c()
@@ -117,7 +117,7 @@ def fire_sigint():
117117
try:
118118
target(**kwargs)
119119
except KeyboardInterrupt as e:
120-
assert sigpipe_caught
120+
assert sigcld_caught
121121
else:
122122
assert False # KeyboardInterrupt must be raised
123123

0 commit comments

Comments
 (0)