Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'draft/pyblish_pype_keep_gui_responsive' into feature/45…
Browse files Browse the repository at this point in the history
…1-Fusion_basic_integration
  • Loading branch information
jakubjezek001 committed Aug 21, 2020
2 parents 2a87931 + 53a1dc3 commit bcb7201
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions pype/tools/pyblish_pype/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
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
Expand All @@ -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.
Expand Down Expand Up @@ -231,7 +254,16 @@ def _process(self, plugin, instance=None):
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:
Expand Down

0 comments on commit bcb7201

Please sign in to comment.