Commit 7e4a5655 authored by mathieui's avatar mathieui
Browse files

Fix a traceback when opening an empty log file

parent 8a44d31e
......@@ -120,7 +120,13 @@ class Logger(object):
# searching "\nM" nb times from the end of the file. We use mmap to
# do that efficiently, instead of seek()s and read()s which are costly.
with fd:
m = mmap.mmap(fd.fileno(), 0, prot=mmap.PROT_READ)
m = mmap.mmap(fd.fileno(), 0, prot=mmap.PROT_READ)
except Exception: # file probably empty
log.error('Unable to mmap the log file for (%s)',
os.path.join(log_dir, jid),
pos = m.rfind(b"\nM") # start of messages begin with MI or MR,
# after a \n
# number of message found so far
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment