Catch exceptions from rmtree

This commit is contained in:
Julien Duponchelle committed 2015-01-26 13:54:44 +01:00
1 parent 4518404706
commit df8bdcc152
3 files changed
+38 -3

No files matched your search

+8 -2
View File
@@ -195,7 +195,10 @@ class Project:
for vm in self._vms:
vm.close()
if cleanup and os.path.exists(self.path):
yield from wait_run_in_executor(shutil.rmtree, self.path)
try:
yield from wait_run_in_executor(shutil.rmtree, self.path)
except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not delete the project directory: {}".format(e))
@asyncio.coroutine
def commit(self):
@@ -205,7 +208,10 @@ class Project:
vm = self._vms_to_destroy.pop()
directory = self.vm_working_directory(vm)
if os.path.exists(directory):
yield from wait_run_in_executor(shutil.rmtree, directory)
try:
yield from wait_run_in_executor(shutil.rmtree, directory)
except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not delete the project directory: {}".format(e))
self.remove_vm(vm)
@asyncio.coroutine