diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2020-08-16 15:10:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-16 15:10:13 (GMT) |
commit | 2353d77fad7ed9d11d8a4d66b5dd1306cdb94125 (patch) | |
tree | b9237127698f84705a53825ff2f466b673d02237 /Lib/logging | |
parent | fff3c28052e6b0750d6218e00acacd2fded4991a (diff) | |
download | cpython-2353d77fad7ed9d11d8a4d66b5dd1306cdb94125.zip cpython-2353d77fad7ed9d11d8a4d66b5dd1306cdb94125.tar.gz cpython-2353d77fad7ed9d11d8a4d66b5dd1306cdb94125.tar.bz2 |
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 4a120e9..867ef4e 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): """ |