4646## @{
4747
4848def handle_process_output (process , stdout_handler , stderr_handler , finalizer ):
49- """Registers for notifications to lean that process output is ready to read, and dispatches lines to
50- the respective line handlers. We are able to handle carriage returns in case progress is sent by that
49+ """Registers for notifications to lean that process output is ready to read, and dispatches lines to
50+ the respective line handlers. We are able to handle carriage returns in case progress is sent by that
5151 mean. For performance reasons, we only apply this to stderr.
5252 This function returns once the finalizer returns
5353 :return: result of finalizer
@@ -77,7 +77,7 @@ def read_line_slow(stream):
7777 def dispatch_line (fno ):
7878 stream , handler , readline = fdmap [fno ]
7979 # this can possibly block for a while, but since we wake-up with at least one or more lines to handle,
80- # we are good ...
80+ # we are good ...
8181 line = readline (stream ).decode (defenc )
8282 if line and handler :
8383 handler (line )
@@ -93,13 +93,13 @@ def deplete_buffer(fno, wg=None):
9393 # end deplete buffer
9494 if wg :
9595 wg .done ()
96- # end
96+ # end
9797
98- fdmap = { process .stdout .fileno () : (process .stdout , stdout_handler , read_line_fast ),
99- process .stderr .fileno () : (process .stderr , stderr_handler , read_line_slow ) }
98+ fdmap = {process .stdout .fileno (): (process .stdout , stdout_handler , read_line_fast ),
99+ process .stderr .fileno (): (process .stderr , stderr_handler , read_line_slow )}
100100
101101 if hasattr (select , 'poll' ):
102- # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
102+ # poll is preferred, as select is limited to file handles up to 1024 ... . This could otherwise be
103103 # an issue for us, as it matters how many handles or own process has
104104 poll = select .poll ()
105105 READ_ONLY = select .POLLIN | select .POLLPRI | select .POLLHUP | select .POLLERR
@@ -137,18 +137,18 @@ def deplete_buffer(fno, wg=None):
137137 wg = WaitGroup ()
138138 for fno in fdmap .keys ():
139139 wg .add (1 )
140- t = threading .Thread (target = lambda : deplete_buffer (fno , wg ))
140+ t = threading .Thread (target = lambda : deplete_buffer (fno , wg ))
141141 t .start ()
142142 # end
143- # NOTE: Just joining threads can possibly fail as there is a gap between .start() and when it's
143+ # NOTE: Just joining threads can possibly fail as there is a gap between .start() and when it's
144144 # actually started, which could make the wait() call to just return because the thread is not yet
145145 # active
146146 wg .wait ()
147147 # end
148148
149149 return finalizer (process )
150150
151-
151+
152152def dashify (string ):
153153 return string .replace ('_' , '-' )
154154
0 commit comments