@@ -2868,7 +2868,7 @@ def _read():
28682868 try :
28692869 wio = self .io .open (w , ** fdopen_kwargs )
28702870 t .start ()
2871- signal .alarm ( 1 )
2871+ signal .setitimer ( signal . ITIMER_REAL , 0. 1 )
28722872 # Fill the pipe enough that the write will be blocking.
28732873 # It will be interrupted by the timer armed above. Since the
28742874 # other thread has read one byte, the low-level write will
@@ -2912,7 +2912,7 @@ def on_alarm(*args):
29122912 r , w = os .pipe ()
29132913 wio = self .io .open (w , ** fdopen_kwargs )
29142914 try :
2915- signal .alarm ( 1 )
2915+ signal .setitimer ( signal . ITIMER_REAL , 0. 1 )
29162916 # Either the reentrant call to wio.write() fails with RuntimeError,
29172917 # or the signal handler raises ZeroDivisionError.
29182918 with self .assertRaises ((ZeroDivisionError , RuntimeError )) as cm :
@@ -2947,7 +2947,7 @@ def alarm_handler(sig, frame):
29472947 try :
29482948 rio = self .io .open (r , ** fdopen_kwargs )
29492949 os .write (w , b"foo" )
2950- signal .alarm ( 1 )
2950+ signal .setitimer ( signal . ITIMER_REAL , 0. 1 )
29512951 # Expected behaviour:
29522952 # - first raw read() returns partial b"foo"
29532953 # - second raw read() returns EINTR
@@ -2991,13 +2991,13 @@ def _read():
29912991 t .daemon = True
29922992 def alarm1 (sig , frame ):
29932993 signal .signal (signal .SIGALRM , alarm2 )
2994- signal .alarm ( 1 )
2994+ signal .setitimer ( signal . ITIMER_REAL , 0. 1 )
29952995 def alarm2 (sig , frame ):
29962996 t .start ()
29972997 signal .signal (signal .SIGALRM , alarm1 )
29982998 try :
29992999 wio = self .io .open (w , ** fdopen_kwargs )
3000- signal .alarm ( 1 )
3000+ signal .setitimer ( signal . ITIMER_REAL , 0. 1 )
30013001 # Expected behaviour:
30023002 # - first raw write() is partial (because of the limited pipe buffer
30033003 # and the first alarm)
0 commit comments