Try harder to ensure that all temporary files are deleted on windows

This commit is contained in:
Kovid Goyal 2011-03-04 09:46:39 -07:00
parent 8b145422f7
commit 71a9332dc5
2 changed files with 12 additions and 0 deletions

View File

@ -94,7 +94,14 @@ class Worker(object):
if not hasattr(self, 'child'): return None if not hasattr(self, 'child'): return None
return getattr(self.child, 'pid', None) return getattr(self.child, 'pid', None)
def close_log_file(self):
try:
self._file.close()
except:
pass
def kill(self): def kill(self):
self.close_log_file()
try: try:
if self.is_alive: if self.is_alive:
if iswindows: if iswindows:

View File

@ -34,6 +34,7 @@ class ConnectedWorker(Thread):
self.killed = False self.killed = False
self.log_path = worker.log_path self.log_path = worker.log_path
self.rfile = rfile self.rfile = rfile
self.close_log_file = getattr(worker, 'close_log_file', None)
def start_job(self, job): def start_job(self, job):
notification = PARALLEL_FUNCS[job.name][-1] is not None notification = PARALLEL_FUNCS[job.name][-1] is not None
@ -185,6 +186,10 @@ class Server(Thread):
# Remove finished jobs # Remove finished jobs
for worker in [w for w in self.workers if not w.is_alive]: for worker in [w for w in self.workers if not w.is_alive]:
try:
worker.close_log_file()
except:
pass
self.workers.remove(worker) self.workers.remove(worker)
job = worker.job job = worker.job
if worker.returncode != 0: if worker.returncode != 0: