class QInterpy(QtCore.QThread): finished = QtCore.pyqtSignal() mutex = QtCore.QMutex() def __init__(self, locals={}, *args, **kwargs): super(QInterpy, self).__init__(*args, **kwargs) self.interpy = Interpy(locals) self.locals = self.interpy.locals def run(self): QInterpy.mutex.lock() sys.stdout = WriteStream(queue) self.interpy.runsource(self.source, self.filename, symbol="exec") self.locals = dict(self.interpy.locals) sys.stdout = sys.__stdout__ QInterpy.mutex.unlock() self.finished.emit() def runsource(self, source, filename="<source>"): self.source = source self.filename = filename def __del__(self): QInterpy.mutex.unlock() self.wait()
class QInterpy(QtCore.QThread): finished = QtCore.pyqtSignal() mutex = QtCore.QMutex() def __init__(self, locals={}, *args, **kwargs): super(QInterpy, self).__init__(*args, **kwargs) self.interpy = Interpy(locals) self.locals = self.interpy.locals def run(self): QInterpy.mutex.lock() sys.stdout = WriteStream(queue) self.interpy.runsource(self.source, self.filename, symbol='exec') self.locals = dict(self.interpy.locals) sys.stdout = sys.__stdout__ QInterpy.mutex.unlock() self.finished.emit() def runsource(self, source, filename="<source>"): self.source = source self.filename = filename def __del__(self): QInterpy.mutex.unlock() self.wait()
def __init__(self, locals={}, *args, **kwargs): super(QInterpy, self).__init__(*args, **kwargs) self.interpy = Interpy(locals) self.locals = self.interpy.locals