Close log file descriptors after write (low ulimit platform)
This commit is contained in:
parent
f092b8cb20
commit
ee7a1fc043
1 changed files with 14 additions and 4 deletions
18
profile.py
18
profile.py
|
@ -77,13 +77,23 @@ class PesterLog(object):
|
|||
PchumLog.debug("post-error msg")
|
||||
|
||||
self.convos[handle][format] = fp
|
||||
|
||||
for (format, t) in modes.items():
|
||||
f = self.convos[handle][format]
|
||||
if platform.system() == "Windows":
|
||||
f.write(t+"\r\n")
|
||||
else:
|
||||
f.write(t+"\r\n")
|
||||
f.write(t+"\r\n")
|
||||
|
||||
# flush + fsync force a write, might not be required though.
|
||||
for (format, t) in modes.items():
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
|
||||
# This way the file descriptors are closed and reopened for every message,
|
||||
# which is sub-optimal and definitely a performance drain but,
|
||||
# otherwise we still run into the ulimit on platforms like MacOS fairly easily.
|
||||
if ostools.isOSX() == True:
|
||||
for (format, t) in modes.items():
|
||||
self.finish(handle)
|
||||
|
||||
def finish(self, handle):
|
||||
if handle not in self.convos:
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue