|
@@ -175,54 +175,59 @@ class JobRunner:
|
|
|
callback(job)
|
|
|
|
|
|
# run function and track progress
|
|
|
- generator = pool.spawn(executable, *args, **kwargs).wait()
|
|
|
- result = generator
|
|
|
-
|
|
|
- if isinstance(generator, GeneratorType):
|
|
|
- iterator = iter(generator)
|
|
|
-
|
|
|
- try:
|
|
|
- while True:
|
|
|
- # run until next progress event
|
|
|
- progress = pool.spawn(self.__next, iterator).wait()
|
|
|
-
|
|
|
- # raise StopIteration if return is of this type
|
|
|
- if isinstance(progress, StopIteration):
|
|
|
- raise progress
|
|
|
-
|
|
|
- # execute progress function
|
|
|
- if progress_fun is not None:
|
|
|
- if isinstance(progress, tuple):
|
|
|
- progress = progress_fun(*progress)
|
|
|
- else:
|
|
|
- progress = progress_fun(progress)
|
|
|
-
|
|
|
- # execute progress listeners
|
|
|
- job.progress = progress
|
|
|
- job.updated = int(time())
|
|
|
-
|
|
|
- for callback in self.__progress_listeners:
|
|
|
- callback(job)
|
|
|
- except StopIteration as stop_iteration_exception:
|
|
|
- result = stop_iteration_exception.value
|
|
|
-
|
|
|
- # update progress
|
|
|
- job.progress = 1
|
|
|
- job.updated = int(time())
|
|
|
-
|
|
|
- for callback in self.__progress_listeners:
|
|
|
- callback(job)
|
|
|
-
|
|
|
- # execute result function
|
|
|
- if result_fun is not None:
|
|
|
- if isinstance(result, tuple):
|
|
|
- result_fun(*result)
|
|
|
- else:
|
|
|
- result_fun(result)
|
|
|
-
|
|
|
- # execute event
|
|
|
- if result_event is not None:
|
|
|
- result_event.send(result)
|
|
|
+ try:
|
|
|
+ generator = pool.spawn(executable, *args, **kwargs).wait()
|
|
|
+ result = generator
|
|
|
+
|
|
|
+ if isinstance(generator, GeneratorType):
|
|
|
+ iterator = iter(generator)
|
|
|
+
|
|
|
+ try:
|
|
|
+ while True:
|
|
|
+ # run until next progress event
|
|
|
+ progress = pool.spawn(self.__next, iterator).wait()
|
|
|
+
|
|
|
+ # raise StopIteration if return is of this type
|
|
|
+ if isinstance(progress, StopIteration):
|
|
|
+ raise progress
|
|
|
+
|
|
|
+ # execute progress function
|
|
|
+ if progress_fun is not None:
|
|
|
+ if isinstance(progress, tuple):
|
|
|
+ progress = progress_fun(*progress)
|
|
|
+ else:
|
|
|
+ progress = progress_fun(progress)
|
|
|
+
|
|
|
+ # execute progress listeners
|
|
|
+ job.progress = progress
|
|
|
+ job.updated = int(time())
|
|
|
+
|
|
|
+ for callback in self.__progress_listeners:
|
|
|
+ callback(job)
|
|
|
+ except StopIteration as stop_iteration_exception:
|
|
|
+ result = stop_iteration_exception.value
|
|
|
+
|
|
|
+ # update progress
|
|
|
+ job.progress = 1
|
|
|
+ job.updated = int(time())
|
|
|
+
|
|
|
+ for callback in self.__progress_listeners:
|
|
|
+ callback(job)
|
|
|
+
|
|
|
+ # execute result function
|
|
|
+ if result_fun is not None:
|
|
|
+ if isinstance(result, tuple):
|
|
|
+ result_fun(*result)
|
|
|
+ else:
|
|
|
+ result_fun(result)
|
|
|
+
|
|
|
+ # execute event
|
|
|
+ if result_event is not None:
|
|
|
+ result_event.send(result)
|
|
|
+
|
|
|
+ # save exceptions to show in ui
|
|
|
+ except Exception as e:
|
|
|
+ job.exception = f'{type(e).__name__} ({str(e)})'
|
|
|
|
|
|
# remove from group dict
|
|
|
if group is not None:
|