diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2020-08-16 16:10:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-16 16:10:13 +0100 |
commit | 2353d77fad7ed9d11d8a4d66b5dd1306cdb94125 (patch) | |
tree | b9237127698f84705a53825ff2f466b673d02237 /Lib/logging | |
parent | fff3c28052e6b0750d6218e00acacd2fded4991a (diff) | |
download | cpython-git-2353d77fad7ed9d11d8a4d66b5dd1306cdb94125.tar.gz |
bpo-41503: Fix race between setTarget and flush in logging.handlers.MemoryHandler (GH-21765)
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/handlers.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 4a120e9f1e..867ef4ebc7 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -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): """ |