@@ -244,9 +244,9 @@ trip_signal(int sig_num)
244244 _PyEval_SignalReceived ();
245245
246246 /* And then write to the wakeup fd *after* setting all the globals and
247- doing the Py_AddPendingCall . We used to write to the wakeup fd and then
248- set the flag, but this allowed the following sequence of events
249- (especially on windows, where trip_signal runs in a new thread):
247+ doing the _PyEval_SignalReceived . We used to write to the wakeup fd
248+ and then set the flag, but this allowed the following sequence of events
249+ (especially on windows, where trip_signal may run in a new thread):
250250
251251 - main thread blocks on select([wakeup_fd], ...)
252252 - signal arrives
@@ -281,6 +281,8 @@ trip_signal(int sig_num)
281281 wakeup .send_err_set = 1 ;
282282 wakeup .send_errno = errno ;
283283 wakeup .send_win_error = GetLastError ();
284+ /* Py_AddPendingCall() isn't signal-safe, but we
285+ still use it for this exceptional case. */
284286 Py_AddPendingCall (report_wakeup_send_error , NULL );
285287 }
286288 }
@@ -294,6 +296,8 @@ trip_signal(int sig_num)
294296 rc = _Py_write_noraise (fd , & byte , 1 );
295297
296298 if (rc < 0 ) {
299+ /* Py_AddPendingCall() isn't signal-safe, but we
300+ still use it for this exceptional case. */
297301 Py_AddPendingCall (report_wakeup_write_error ,
298302 (void * )(intptr_t )errno );
299303 }
0 commit comments