@@ -705,8 +705,11 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
705
705
time .sleep (1 )
706
706
if process .returncode is not None :
707
707
if cleanup_cidfile :
708
- os .remove (cidfile )
709
- return
708
+ try :
709
+ os .remove (cidfile )
710
+ except OSError as exc :
711
+ _logger .warn ("Ignored error cleaning up Docker cidfile: %s" , exc )
712
+ return
710
713
try :
711
714
with open (cidfile ) as cidhandle :
712
715
cid = cidhandle .readline ().strip ()
@@ -715,12 +718,16 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
715
718
max_mem = psutil .virtual_memory ().total
716
719
tmp_dir , tmp_prefix = os .path .split (tmpdir_prefix )
717
720
stats_file = tempfile .NamedTemporaryFile (prefix = tmp_prefix , dir = tmp_dir )
718
- with open (stats_file .name , mode = "w" ) as stats_file_handle :
719
- stats_proc = subprocess .Popen (
720
- ['docker' , 'stats' , '--no-trunc' , '--format' , '{{.MemPerc}}' ,
721
- cid ], stdout = stats_file_handle , stderr = subprocess .DEVNULL )
722
- process .wait ()
723
- stats_proc .kill ()
721
+ try :
722
+ with open (stats_file .name , mode = "w" ) as stats_file_handle :
723
+ stats_proc = subprocess .Popen (
724
+ ['docker' , 'stats' , '--no-trunc' , '--format' , '{{.MemPerc}}' ,
725
+ cid ], stdout = stats_file_handle , stderr = subprocess .DEVNULL )
726
+ process .wait ()
727
+ stats_proc .kill ()
728
+ except OSError as exc :
729
+ _logger .warn ("Ignored error with docker stats: %s" , exc )
730
+ return
724
731
max_mem_percent = 0
725
732
with open (stats_file .name , mode = "r" ) as stats :
726
733
for line in stats :
0 commit comments