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

(cherry picked from commit 2353d77fad)


Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>

Automerge-Triggered-By: @vsajip
This commit is contained in:
Miss Islington (bot) 2020-08-16 08:34:27 -07:00 committed by GitHub
parent 28bf82661a
commit 2c050e52f1
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):
"""