From 4a0d419f85ef50ca06f7a8cdfa65a7d7cf93a0dc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 2 Apr 2021 11:47:14 -0400 Subject: [PATCH] Improve behavior on python2 systems --- confluent_server/confluent/consoleserver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluent/consoleserver.py index ee4e6cd8..152fa162 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -66,7 +66,7 @@ def get_buffer_output(nodename): instream = _bufferdaemon.stdout if not isinstance(nodename, bytes): nodename = nodename.encode('utf8') - outdata = b'' + outdata = bytearray() with _bufferlock: out.write(struct.pack('I', len(nodename))) out.write(nodename) @@ -75,10 +75,10 @@ def get_buffer_output(nodename): while not outdata or outdata[-1]: chunk = instream.read(128) if chunk: - outdata += chunk + outdata.extend(chunk) else: select.select((instream,), (), (), 0) - return outdata[:-1] + return bytes(outdata[:-1]) def send_output(nodename, output): @@ -590,7 +590,7 @@ def start_console_sessions(): _bufferlock = semaphore.Semaphore() _tracelog = log.Logger('trace') _bufferdaemon = subprocess.Popen( - ['/opt/confluent/bin/vtbufferd'], stdin=subprocess.PIPE, + ['/opt/confluent/bin/vtbufferd'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE) fl = fcntl.fcntl(_bufferdaemon.stdout.fileno(), fcntl.F_GETFL) fcntl.fcntl(_bufferdaemon.stdout.fileno(),