@@ -4095,11 +4095,13 @@ def test_broken_pipe_cleanup(self):
40954095
40964096
40974097class FastWaitTestCase (BaseTestCase ):
4098+ """Tests for efficient (pidfd_open / kqueue) process waiting in
4099+ subprocess.Popen.wait().
4100+ """
40984101
40994102 def assert_fast_waitpid_error (self , patch_point ):
41004103 # Emulate a case where pidfd_open() (Linux) or kqueue()
4101- # (BSD/macOS) fails due to too many open files. _busy_wait()
4102- # should be used as fallback.
4104+ # (BSD/macOS) fails. _busy_wait() should be used as fallback.
41034105 exc = OSError (errno .EMFILE , os .strerror (errno .EMFILE ))
41044106 with mock .patch (patch_point , side_effect = exc ) as m :
41054107 p = subprocess .Popen ([sys .executable ,
@@ -4110,21 +4112,21 @@ def assert_fast_waitpid_error(self, patch_point):
41104112 assert m .called
41114113
41124114 @unittest .skipIf (not hasattr (os , "pidfd_open" ), reason = "LINUX only" )
4113- def test_wait_pidfd_open_error (self , patch_point = "os.pidfd_open" ):
4115+ def test_wait_pidfd_open_error (self ):
41144116 self .assert_fast_waitpid_error ("os.pidfd_open" )
41154117
41164118 @unittest .skipIf (
41174119 not subprocess ._can_use_kqueue (), reason = "macOS / BSD only"
41184120 )
4119- def test_wait_kqueue_error (self , patch_point = "os.pidfd_open" ):
4121+ def test_wait_kqueue_error (self ):
41204122 self .assert_fast_waitpid_error ("select.kqueue" )
41214123
41224124 @unittest .skipIf (
41234125 not subprocess ._can_use_kqueue (), reason = "macOS / BSD only"
41244126 )
41254127 def test_kqueue_control_error (self ):
4126- # Emulate a case where kqueue.control() fails due to too many
4127- # open files. _busy_wait() should be used as fallback.
4128+ # Emulate a case where kqueue.control() fails. _busy_wait()
4129+ # should be used as fallback.
41284130 p = subprocess .Popen ([sys .executable ,
41294131 "-c" , "import time; time.sleep(0.3)" ])
41304132 kq_mock = mock .Mock ()
@@ -4139,11 +4141,10 @@ def test_kqueue_control_error(self):
41394141 self .assertEqual (p .wait (timeout = support .SHORT_TIMEOUT ), 0 )
41404142 assert m .called
41414143
4142-
4143- def assert_wait_pid_race (self , patch_target , real_func ):
4144+ def assert_wait_race_condition (self , patch_target , real_func ):
41444145 # Call pidfd_open() / kqueue(), then terminate the process.
4145- # Make sure that the next poll() / kqueue.control() call still
4146- # works for a terminated PID.
4146+ # Make sure that the wait call ( poll() / kqueue.control())
4147+ # still works for a terminated PID.
41474148 p = subprocess .Popen ([sys .executable ,
41484149 "-c" , "import time; time.sleep(0.3)" ])
41494150
@@ -4160,13 +4161,13 @@ def wrapper(*args, **kwargs):
41604161
41614162 @unittest .skipIf (not hasattr (os , "pidfd_open" ), reason = "LINUX only" )
41624163 def test_pidfd_open_race (self ):
4163- self .assert_wait_pid_race ("os.pidfd_open" , os .pidfd_open )
4164+ self .assert_wait_race_condition ("os.pidfd_open" , os .pidfd_open )
41644165
41654166 @unittest .skipIf (
41664167 not subprocess ._can_use_kqueue (), reason = "macOS / BSD only"
41674168 )
41684169 def test_kqueue_race (self ):
4169- self .assert_wait_pid_race ("select.kqueue" , select .kqueue )
4170+ self .assert_wait_race_condition ("select.kqueue" , select .kqueue )
41704171
41714172
41724173if __name__ == "__main__" :
0 commit comments