File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def main():
4545 break
4646 # raise Exception if log_file could not be set
4747 if log_file is None:
48- raise Exception("Could not open '.jupyter-server-log.txt' log file " )
48+ raise Exception("Could not open '.jupyter-server-log.txt' log file" )
4949
5050 # build the command
5151 # like `exec "$@"`
@@ -74,23 +74,27 @@ def main():
7474 for signum in SIGNALS:
7575 signal.signal(signum, relay_signal)
7676
77- enospc = {
78- sys.stdout.buffer: False,
79- log_file: False
77+ # keep a record of the output streams that ran out space
78+ writable = {
79+ sys.stdout.buffer: True,
80+ log_file: True
8081 }
8182
8283 # tee output from child to both our stdout and the log file
8384 def tee(chunk):
84- """Tee output from child to the log file"""
85+ """Tee output from child to both our stdout and the log file"""
8586 for f in [sys.stdout.buffer, log_file]:
86- if not enospc [f]:
87+ if writable [f]:
8788 try:
8889 f.write(chunk)
8990 f.flush()
9091 except OSError as e:
9192 if e.errno == errno.ENOSPC:
92- enospc[f] = True
93+ # mark the stream as not writable anymore
94+ writable[f] = False
9395 continue
96+ else:
97+ raise
9498
9599 # make stdout pipe non-blocking
96100 # this means child.stdout.read(nbytes)
@@ -118,6 +122,8 @@ def main():
118122 tee(chunk)
119123 chunk = child.stdout.read()
120124
125+ log_file.close()
126+
121127 # make our returncode match the child's returncode
122128 sys.exit(child.returncode)
123129
You can’t perform that action at this time.
0 commit comments