bpo-41503: Fix race between setTarget and flush in logging.handlers.MemoryHandler (GH-21765)

This commit is contained in:
Irit Katriel 2020-08-16 16:10:13 +01:00 committed by GitHub
parent fff3c28052
commit 2353d77fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -1324,7 +1324,11 @@ class MemoryHandler(BufferingHandler):
"""
Set the target handler for this handler.
"""
self.target = target
self.acquire()
try:
self.target = target
finally:
self.release()
def flush(self):
"""