diff --git a/pype/tools/pyblish_pype/control.py b/pype/tools/pyblish_pype/control.py index 0162848f2b..d73c7efad7 100644 --- a/pype/tools/pyblish_pype/control.py +++ b/pype/tools/pyblish_pype/control.py @@ -9,8 +9,10 @@ import os import sys import traceback import inspect +import threading -from Qt import QtCore +import six +from Qt import QtCore, QtWidgets import pyblish.api import pyblish.util @@ -28,6 +30,27 @@ class IterationBreak(Exception): pass +class ProcessThread(threading.Thread): + def __init__(self, plugin, context, instance): + super(ProcessThread, self).__init__() + + self.result = None + self.exception = None + + self.plugin = plugin + self.context = context + self.instance = instance + + def run(self): + try: + result = pyblish.plugin.process( + self.plugin, self.context, self.instance + ) + self.result = result + except Exception: + self.exception = sys.exc_info() + + class Controller(QtCore.QObject): # Emitted when the GUI is about to start processing; # e.g. resetting, validating or publishing. @@ -231,7 +254,16 @@ class Controller(QtCore.QObject): self.processing["nextOrder"] = plugin.order try: - result = pyblish.plugin.process(plugin, self.context, instance) + thread = ProcessThread(plugin, self.context, instance) + thread.start() + while thread.isAlive(): + QtWidgets.QApplication.processEvents() + + thread.join() + if thread.exception: + six.reraise(*thread.exception) + + result = thread.result # Make note of the order at which the # potential error error occured. if result["error"] is not None: