@@ -29,7 +29,9 @@ def duplicate_for_child(self, fd):
2929 def poll (self , flag = os .WNOHANG ):
3030 with self ._exit_condition :
3131 if self .returncode is not None :
32+ """
3233 self._logs.append('r')
34+ """
3335 return self .returncode
3436 if flag & os .WNOHANG :
3537 return self ._nonblocking_poll (flag )
@@ -47,34 +49,42 @@ def poll(self, flag=os.WNOHANG):
4749 pass
4850
4951 with self ._exit_condition :
50- #self._logs.append(f'-{self._exit_blockers}-')
52+ """
53+ self._logs.append(f'-{self._exit_blockers}-')
54+ """
5155 self ._exit_blockers -= 1
52- """"""
56+ """
5357 if self.returncode is not None:
5458 self._logs.append('r')
5559 return self.returncode
56- """"""
60+ """
5761 if pid == self .pid :
5862 self ._set_returncode (sts )
5963 elif self ._exit_blockers == 0 : # forcing th test changing the elif to if
64+ """
6065 n = len(self._exit_condition._waiters)
6166 if n > 0:
6267 self._logs.append('N'*n)
6368 else:
6469 self._logs.append('!N')
70+ """
6571 self ._exit_condition .notify_all ()
6672
6773 while self .returncode is None and self ._exit_blockers > 0 :
74+ """
6875 if self.returncode is not None:
6976 self._logs.append('w')
7077 else:
7178 self._logs.append('W')
79+ """
7280 self ._exit_condition .wait ()
7381
82+ """
7483 if self.returncode is not None:
7584 self._logs.append('r')
7685 else:
7786 self._logs.append('R')
87+ """
7888 return self .returncode
7989
8090 def _nonblocking_poll (self , flag ):
@@ -85,29 +95,33 @@ def _nonblocking_poll(self, flag):
8595 pid , sts = os .waitpid (self .pid , flag )
8696 if pid == self .pid :
8797 self ._set_returncode (sts )
88- except OSError :
98+ except OSError as e :
8999 # See comments in the poll(...) except clause above
90100 pass
91101
92102 # We may be racing with a blocking wait call, in which case (if we lose
93103 # the race) it is arbitrary whether this returns None or the exit code
94104 # (if there is one): calling code must always be prepared to handle a
95105 # situation where this method returns None but the process has ended.
106+ """
96107 if self.returncode is not None:
97108 self._logs.append('x')
98109 else:
99110 self._logs.append('X')
111+ """
100112 return self .returncode
101113
102114 def _set_returncode (self , sts ):
103115 assert self ._exit_condition ._is_owned ()
104116 assert self .returncode is None
105117 self .returncode = os .waitstatus_to_exitcode (sts )
118+ """
106119 n = len(self._exit_condition._waiters)
107120 if n > 0:
108121 self._logs.append('n'*n)
109122 else:
110123 self._logs.append('!n')
124+ """
111125 self ._exit_condition .notify_all ()
112126
113127 def wait (self , timeout = None ):
0 commit comments