@@ -0,0 +1,1380 @@
+try:%0A    import queue%0Aexcept ImportError:%0A    import Queue as queue%0Afrom .future import Future%0Afrom . import Qt%0A%0A%0Adef runInThread(thread, func, *args, **kwds):%0A    %22%22%22Run a function in another thread and return the result.%0A%0A    The remote thread must be running a Qt event loop.%0A    %22%22%22%0A    return ThreadCallFuture(thread, func, *args, **kwds)()%0A%0A%0Adef runInGuiThread(func, *args, **kwds):%0A    %22%22%22Run a function the main GUI thread and return the result.%0A    %22%22%22%0A    return ThreadCallFuture(None, func, *args, **kwds)()%0A%0A%0Aclass ThreadCallFuture(Future):%0A    sigRequestCall = Qt.Signal()%0A    def __init__(self, thread, func, *args, **kwds):%0A        Future.__init__(self)%0A        self.func = func%0A        self.args = args%0A        self.kwds = kwds%0A        self.exc = None%0A%0A        if thread is None:%0A            thread = Qt.QApplication.instance().thread()%0A        self.moveToThread(thread)%0A        self.sigRequestCall.connect(self._callRequested)%0A        self.sigRequestCall.emit()%0A%0A    def _callRequested(self):%0A        try:%0A            self.ret = self.func(*self.args, **self.kwds)%0A            self._taskDone()%0A        except Exception as exc:%0A            self.exc = exc%0A            self._taskDone(interrupted=True, error=str(exc))%0A%0A    def __call__(self):%0A        self.wait()%0A        if self.exc is not None:%0A            raise self.exc%0A        else:%0A            return self.ret%0A%0A%0A

Add utility for calling functions across threads directly