mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Be careful with logging locks and unopened streams
Slight modification of patch suggested by sirkonst.
This commit is contained in:
parent
ac223ae639
commit
1757567d2f
@ -206,18 +206,24 @@ class Logger(object):
|
||||
for handler in log.handlers:
|
||||
if isinstance(handler, logging.FileHandler):
|
||||
handler.acquire()
|
||||
handler.stream.close()
|
||||
handler.stream = open(handler.baseFilename,
|
||||
handler.mode)
|
||||
handler.release()
|
||||
try:
|
||||
if handler.stream:
|
||||
handler.stream.close()
|
||||
handler.stream = open(handler.baseFilename,
|
||||
handler.mode)
|
||||
finally:
|
||||
handler.release()
|
||||
|
||||
def close_on_exec(self):
|
||||
for log in (self.error_log, self.access_log):
|
||||
for handler in log.handlers:
|
||||
if isinstance(handler, logging.FileHandler):
|
||||
handler.acquire()
|
||||
util.close_on_exec(handler.stream.fileno())
|
||||
handler.release()
|
||||
try:
|
||||
if handler.stream:
|
||||
util.close_on_exec(handler.stream.fileno())
|
||||
finally:
|
||||
handler.release()
|
||||
|
||||
|
||||
def _get_gunicorn_handler(self, log):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user