As it stands, a QThread worker class enables the external call of an *.exe with Popen. While this external process is running, a QProgressBar within the governing class needs to be periodically updated.
The sample below works for a few percentage increments, then it suddenly freezes until the process is complete.
progress = pyqtSignal(int)
def runProgram(self,directory):
file = directory+'fileName.txt'
program = sys.path[4] + "/Root/GIS_Pre_Processor.exe"
runProgram = Popen([program,file],shell=True,cwd=directory)
currentProgress = 45
while runProgram.poll() is None:
time.sleep(1.5) #<=== makes it through a couple of these loops
currentProgress = currentProgress + 5
self.progress.emit(currentProgress)
self.progress.emit(100)
class workerThread(QThread):
progress = pyqtSignal(int)
def runProgram(self,directory):
file = directory+'fileName.txt'
program = sys.path[4] + "/Root/GIS_Pre_Processor.exe"
runProgram = Popen([program,file],shell=True,cwd=directory)
currentProgress = 45
while runProgram.poll() is None:
time.sleep(1.5) #<=== makes it through a couple of these loops
currentProgress = currentProgress + 5
self.progress.emit(currentProgress)
self.progress.emit(100)
To copy to clipboard, switch view to plain text mode
Does this suggest an improper implementation of QThread?
Bookmarks