From 5a69da392f8951fa3716c81f81f1ecaf5dfe3480 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Wed, 30 Sep 2020 21:26:34 +0200 Subject: [PATCH] Fix python2 AttributeError with strptime Fix a potential python2 error when calling strptime, the first call to strptime is not thread safe and might trigger an exception. A workaround was added by calling strptime before creating a thread but the caller is itself within a thread, so it may fail. The workaround is now to explicitly import _strptime as described in the upstream python issue https://bugs.python.org/issue7980 Note: This commit only applies to branches that support python2 (initial commit in stable/train) Story 2008211 Task 40997 Change-Id: I0e7119d5a379f8662c4913d7232ef28535a29b32 --- octavia/common/base_taskflow.py | 3 +++ ...ix-python2-attributeerror-strptime-89a7350c55ac8818.yaml | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 releasenotes/notes/fix-python2-attributeerror-strptime-89a7350c55ac8818.yaml diff --git a/octavia/common/base_taskflow.py b/octavia/common/base_taskflow.py index 4fb3e3a183..1d072cc955 100644 --- a/octavia/common/base_taskflow.py +++ b/octavia/common/base_taskflow.py @@ -16,6 +16,9 @@ import concurrent.futures import datetime +# work around for https://bugs.python.org/issue7980 +import _strptime # noqa: F401 pylint: disable=unused-import + from oslo_config import cfg from taskflow import engines as tf_engines diff --git a/releasenotes/notes/fix-python2-attributeerror-strptime-89a7350c55ac8818.yaml b/releasenotes/notes/fix-python2-attributeerror-strptime-89a7350c55ac8818.yaml new file mode 100644 index 0000000000..95eaf051df --- /dev/null +++ b/releasenotes/notes/fix-python2-attributeerror-strptime-89a7350c55ac8818.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix a potential AttributeError exception at init time in the housekeeping + service when using python2 because of an issue with thread safety when + calling strptime for the first time.