@@ -183,21 +183,30 @@ def start(self):
183183 self ._redirect_display (True )
184184 self ._reset_global_env = True
185185
186+ def _proc_log_enabled (self ):
187+ # process log is enabled only for logging.DEBUG
188+ log .isEnabledFor (logging .DEBUG )
189+
186190 def _popen (self , use_pass_fds ):
191+ if self ._proc_log_enabled ():
192+ stdout_stderr = subprocess .PIPE
193+ else :
194+ stdout_stderr = subprocess .DEVNULL
195+
187196 with _mutex_popen :
188197 if use_pass_fds :
189198 self ._subproc = subprocess .Popen (
190199 self ._command ,
191200 pass_fds = [self ._pipe_wfd ],
192- stdout = subprocess . PIPE ,
193- stderr = subprocess . PIPE ,
201+ stdout = stdout_stderr ,
202+ stderr = stdout_stderr ,
194203 shell = False ,
195204 )
196205 else :
197206 self ._subproc = subprocess .Popen (
198207 self ._command ,
199- stdout = subprocess . PIPE ,
200- stderr = subprocess . PIPE ,
208+ stdout = stdout_stderr ,
209+ stderr = stdout_stderr ,
201210 shell = False ,
202211 )
203212
@@ -366,11 +375,12 @@ def stop(self):
366375 return self
367376
368377 def _read_stdout_stderr (self ):
369- if self .stdout is None :
370- (self .stdout , self .stderr ) = self ._subproc .communicate ()
378+ if self ._proc_log_enabled ():
379+ if self .stdout is None :
380+ (self .stdout , self .stderr ) = self ._subproc .communicate ()
371381
372- log .debug ("stdout=%s" , self .stdout )
373- log .debug ("stderr=%s" , self .stderr )
382+ log .debug ("stdout=%s" , self .stdout )
383+ log .debug ("stderr=%s" , self .stderr )
374384
375385 def _setup_xauth (self ):
376386 """
0 commit comments