Make stdout unbuffered
This commit is contained in:
parent
a52e6d968c
commit
c3a11254bb
@ -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
|
||||||
@ -112,4 +113,4 @@ def main():
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user