Flush buffer for QProcess in PyQt5
Hi everyone!
I have a Python 3.4 app using the PyQt5 framework and I'm having an issue.
I setup a QProcess:
Code:
def listenToServer(self, MainWindow):
self.ws.start("python3 /home/pi/scara_panel/ws.py")
self.ws.readyReadStandardOutput.connect(self.processServer)
And it calls this function:
Code:
def processServer(self):
income = str(self.ws.readAllStandardOutput())
print(income)
On a desktop, it works fine. It flows into to the app. However, when the program is run on a Raspberry Pi, it only displays what its read once the script ws.py terminates.
I've read that this has to do with output buffering in Python. I've tried things like adding the -u flag, but no dice. Any suggestions on how to clear this buffer when using readAllStandardOutput()?
I've tried implementing a few things from http://stackoverflow.com/questions/1...tput-buffering but nothing seems to fix the issue.
Any help is appreciated!
Re: Flush buffer for QProcess in PyQt5
Strange, as usually there is very little to no difference between running on desktop Linux and on embedded Linux, especially on the Pi as this is often desktop Linux, just for ARM (e.g. Rasphian).
Have you tried the "-u" switch with the better QProcess start() overload?
The one that takes the program to run and the arguments as a list?
Cheers,
_
Re: Flush buffer for QProcess in PyQt5
Quote:
Originally Posted by
anda_skoa
Strange, as usually there is very little to no difference between running on desktop Linux and on embedded Linux, especially on the Pi as this is often desktop Linux, just for ARM (e.g. Rasphian).
Have you tried the "-u" switch with the better QProcess start() overload?
The one that takes the program to run and the arguments as a list?
Cheers,
_
That did the trick! Thank you so much, I can't believe I hadn't thought of that!