Skip to content

Commit

Permalink
bpo-38781: Clear buffer in MemoryHandler flush (pythonGH-17132)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Penlect authored and vsajip committed Nov 13, 2019
1 parent 9c28449 commit d89cea1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ def flush(self):
"""
self.acquire()
try:
self.buffer = []
self.buffer.clear()
finally:
self.release()

Expand Down Expand Up @@ -1321,7 +1321,7 @@ def flush(self):
if self.target:
for record in self.buffer:
self.target.handle(record)
self.buffer = []
self.buffer.clear()
finally:
self.release()

Expand Down

0 comments on commit d89cea1

Please sign in to comment.