Make stdout unbuffered

This commit is contained in:
Fierelier 2021-12-16 08:39:02 +01:00
parent a52e6d968c
commit c3a11254bb

View File

@ -27,6 +27,7 @@ bufferSize = 8096 # buffer size in bytes
timeout = 15 # timeout in seconds timeout = 15 # timeout in seconds
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
unbufferedStdout = os.fdopen(sys.stdout.fileno(),"wb",0) # Make unbuffered stdout
def listToCommand(lst): def listToCommand(lst):
cmd = "" cmd = ""
@ -95,7 +96,7 @@ def main():
while True: while True:
data = connection.recv(bufferSize) data = connection.recv(bufferSize)
if data == b"": return if data == b"": return
sys.stdout.buffer.write(data) unbufferedStdout.write(data)
except: except:
connection.close() connection.close()
raise raise