Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e13caa4

Browse files
committed
DOC: add note about why reading the socket is complicated
1 parent 9d13e7d commit e13caa4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/matplotlib/backends/qt_compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ def _maybe_allow_interrupt(qapp):
228228
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
229229
)
230230

231+
# We do not actually care about this value other than running some
232+
# Python code to ensure that the interpreter has a chance to handle the
233+
# signal in Python land. We also need to drain the socket because it
234+
# will be written to as part of the wakeup! There are some cases where
235+
# this may fire too soon / more than once on Windows so we should be
236+
# forgiving about reading an empty socket.
231237
rsock.setblocking(False)
232238
# Clear the socket to re-arm the notifier.
233239
@sn.activated.connect

0 commit comments

Comments
 (0)