Merge pull request #114

* Better exception handling / error reporting for add job screen

* Don't supress exceptions for potentially long running functions in bl…

* Increase Blender pack_project_file timeout to 120s
This commit is contained in:
2024-08-20 15:20:24 -05:00
committed by GitHub
parent 751d74ced3
commit e792698480
2 changed files with 83 additions and 62 deletions

View File

@@ -55,7 +55,9 @@ class Blender(BaseRenderEngine):
return subprocess.run([self.renderer_path(), '-b', project_path, '--python-expr', python_expression],
capture_output=True, timeout=timeout, creationflags=_creationflags)
except Exception as e:
logger.error(f"Error running python expression in blender: {e}")
err_msg = f"Error running python expression in blender: {e}"
logger.error(err_msg)
raise ChildProcessError(err_msg)
else:
raise FileNotFoundError(f'Project file not found: {project_path}')
@@ -70,9 +72,16 @@ class Blender(BaseRenderEngine):
command = [self.renderer_path(), '-b', '--python', script_path]
if project_path:
command.insert(2, project_path)
return subprocess.run(command, capture_output=True, timeout=timeout, creationflags=_creationflags)
result = subprocess.run(command, capture_output=True, timeout=timeout, creationflags=_creationflags)
return result
except subprocess.TimeoutExpired:
err_msg = f"Timed out after {timeout}s while running python script in blender: {script_path}"
logger.error(err_msg)
raise TimeoutError(err_msg)
except Exception as e:
logger.exception(f"Error running python script in blender: {e}")
err_msg = f"Error running python script in blender: {e}"
logger.error(err_msg)
raise ChildProcessError(err_msg)
def get_project_info(self, project_path, timeout=10):
scene_info = {}
@@ -89,10 +98,12 @@ class Blender(BaseRenderEngine):
elif line.startswith('Error'):
logger.error(f"get_scene_info error: {line.strip()}")
except Exception as e:
logger.error(f'Error getting file details for .blend file: {e}')
msg = f'Error getting file details for .blend file: {e}'
logger.error(msg)
raise ChildProcessError(msg)
return scene_info
def pack_project_file(self, project_path, timeout=30):
def pack_project_file(self, project_path, timeout=None):
# Credit to L0Lock for pack script - https://blender.stackexchange.com/a/243935
try:
logger.info(f"Starting to pack Blender file: {project_path}")
@@ -115,7 +126,9 @@ class Blender(BaseRenderEngine):
logger.info(f'Blender file packed successfully to {new_path}')
return new_path
except Exception as e:
logger.error(f'Error packing .blend file: {e}')
msg = f'Error packing .blend file: {e}'
logger.error(msg)
raise ChildProcessError(msg)
return None
def get_arguments(self):
@@ -172,7 +185,7 @@ class Blender(BaseRenderEngine):
return render_engines
def perform_presubmission_tasks(self, project_path):
packed_path = self.pack_project_file(project_path, timeout=30)
packed_path = self.pack_project_file(project_path, timeout=120)
return packed_path