From c3a11254bb99012c16e39f007331a7195fc4d2c9 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Thu, 16 Dec 2021 08:39:02 +0100 Subject: [PATCH] Make stdout unbuffered --- client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index e27d706..f7c5079 100644 --- a/client.py +++ b/client.py @@ -27,6 +27,7 @@ bufferSize = 8096 # buffer size in bytes timeout = 15 # timeout in seconds connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +unbufferedStdout = os.fdopen(sys.stdout.fileno(),"wb",0) # Make unbuffered stdout def listToCommand(lst): cmd = "" @@ -95,7 +96,7 @@ def main(): while True: data = connection.recv(bufferSize) if data == b"": return - sys.stdout.buffer.write(data) + unbufferedStdout.write(data) except: connection.close() raise @@ -112,4 +113,4 @@ def main(): raise if __name__ == '__main__': - main() \ No newline at end of file + main()