bpo-38781: Clear buffer in MemoryHandler flush (GH-17132)
This makes it easier to use a custom buffer when subclassing MemoryHandler (by avoiding the explicity empty list literal assignment in the flush method). For example, collection.deque can now be used without any modifications to MemoryHandler.flush. The same applies to BufferingHandler.
This commit is contained in:
parent
9c2844927d
commit
d89cea15ad
|
@ -1254,7 +1254,7 @@ class BufferingHandler(logging.Handler):
|
||||||
"""
|
"""
|
||||||
self.acquire()
|
self.acquire()
|
||||||
try:
|
try:
|
||||||
self.buffer = []
|
self.buffer.clear()
|
||||||
finally:
|
finally:
|
||||||
self.release()
|
self.release()
|
||||||
|
|
||||||
|
@ -1321,7 +1321,7 @@ class MemoryHandler(BufferingHandler):
|
||||||
if self.target:
|
if self.target:
|
||||||
for record in self.buffer:
|
for record in self.buffer:
|
||||||
self.target.handle(record)
|
self.target.handle(record)
|
||||||
self.buffer = []
|
self.buffer.clear()
|
||||||
finally:
|
finally:
|
||||||
self.release()
|
self.release()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue