mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Closed resource leak in SysLogHandler.
This commit is contained in:
parent
9c18778695
commit
fd28502fcf
2 changed files with 28 additions and 31 deletions
|
@ -756,7 +756,6 @@ class SysLogHandler(logging.Handler):
|
|||
"""
|
||||
Closes the socket.
|
||||
"""
|
||||
if self.unixsocket:
|
||||
self.socket.close()
|
||||
logging.Handler.close(self)
|
||||
|
||||
|
|
|
@ -3484,12 +3484,12 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
|
|||
def test_rollover(self):
|
||||
fh = logging.handlers.TimedRotatingFileHandler(self.fn, 'S',
|
||||
backupCount=1)
|
||||
try:
|
||||
r = logging.makeLogRecord({'msg': 'testing'})
|
||||
fh.emit(r)
|
||||
self.assertLogFile(self.fn)
|
||||
time.sleep(1.0)
|
||||
fh.emit(r)
|
||||
fh.close()
|
||||
# At this point, we should have a recent rotated file which we
|
||||
# can test for the existence of. However, in practice, on some
|
||||
# machines which run really slowly, we don't know how far back
|
||||
|
@ -3508,17 +3508,15 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
|
|||
break
|
||||
msg = 'No rotated files found, went back %d seconds' % GO_BACK
|
||||
self.assertTrue(found, msg=msg)
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
def test_invalid(self):
|
||||
assertRaises = self.assertRaises
|
||||
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
||||
self.fn, 'X')
|
||||
self.fn, 'X', delay=True)
|
||||
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
||||
self.fn, 'W')
|
||||
self.fn, 'W', delay=True)
|
||||
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
||||
self.fn, 'W7')
|
||||
self.fn, 'W7', delay=True)
|
||||
|
||||
def secs(**kw):
|
||||
return datetime.timedelta(**kw) // datetime.timedelta(seconds=1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue