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:
|
for handler in log.handlers:
|
||||||
if isinstance(handler, logging.FileHandler):
|
if isinstance(handler, logging.FileHandler):
|
||||||
handler.acquire()
|
handler.acquire()
|
||||||
handler.stream.close()
|
try:
|
||||||
handler.stream = open(handler.baseFilename,
|
if handler.stream:
|
||||||
handler.mode)
|
handler.stream.close()
|
||||||
handler.release()
|
handler.stream = open(handler.baseFilename,
|
||||||
|
handler.mode)
|
||||||
|
finally:
|
||||||
|
handler.release()
|
||||||
|
|
||||||
def close_on_exec(self):
|
def close_on_exec(self):
|
||||||
for log in (self.error_log, self.access_log):
|
for log in (self.error_log, self.access_log):
|
||||||
for handler in log.handlers:
|
for handler in log.handlers:
|
||||||
if isinstance(handler, logging.FileHandler):
|
if isinstance(handler, logging.FileHandler):
|
||||||
handler.acquire()
|
handler.acquire()
|
||||||
util.close_on_exec(handler.stream.fileno())
|
try:
|
||||||
handler.release()
|
if handler.stream:
|
||||||
|
util.close_on_exec(handler.stream.fileno())
|
||||||
|
finally:
|
||||||
|
handler.release()
|
||||||
|
|
||||||
|
|
||||||
def _get_gunicorn_handler(self, log):
|
def _get_gunicorn_handler(self, log):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user