Skip to content

Commit

Permalink
Fix crashes during log stream reading (#542)
Browse files Browse the repository at this point in the history
1. When writing logs using `Logger.info` (say, logging JSONRPC
   requests)
2. Master or slave process calls `asyncio.StreamReader.readline` to get
   the log out
3. However the stream has a buffer limit 64k and will throw exception if
   reached, hence the printing coroutine will crash
4. As a result, the process's pipe may get full because no one is
   consuming, leading the process hang

Fixes #208
  • Loading branch information
ninjaahhh committed Apr 30, 2019
1 parent 25b7cd2 commit 1c5958f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions quarkchain/cluster/cluster.py
Expand Up @@ -49,10 +49,13 @@ async def run_slave(config_file, id):

async def print_output(prefix, stream):
while True:
line = await stream.readline()
if not line:
break
print("{}: {}".format(prefix, line.decode("ascii").strip()))
try:
line = await stream.readline()
if not line:
break
print("{}: {}".format(prefix, line.decode("ascii").strip()))
except Exception as e:
print("{}: reading line exception {}".format(prefix, e))


class Cluster:
Expand Down

0 comments on commit 1c5958f

Please sign in to comment.