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
This commit is contained in:
Gregory Thiemonge 2020-09-30 21:26:34 +02:00
parent 8c32d2e602
commit 5a69da392f
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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.