From 023be4f5615255d06f61b393605da1308f045220 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 8 May 2025 12:38:28 +0100 Subject: [PATCH] wsgi: Don't create, use lock in same line As noted on the mailing list some time back [1], pylint flags this as a useless lock [2]. Make it non-useless. [1] https://lists.openstack.org/archives/list/openstack-discuss@lists.openstack.org/message/CZVC6SEMUSEH7UT5LDHOWL7WBZ2OXUWZ/ [2] https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/useless-with-lock.html Change-Id: If8243cc62c3dd9cd5f5b0d664981975efc6300cc Signed-off-by: Stephen Finucane --- nova/wsgi/metadata.py | 3 ++- nova/wsgi/osapi_compute.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/wsgi/metadata.py b/nova/wsgi/metadata.py index e033b71cec52..fec9ba1be81e 100644 --- a/nova/wsgi/metadata.py +++ b/nova/wsgi/metadata.py @@ -19,6 +19,7 @@ from nova.api.openstack import wsgi_app NAME = "metadata" application = None -with threading.Lock(): +lock = threading.Lock() +with lock: if application is None: application = wsgi_app.init_application(NAME) diff --git a/nova/wsgi/osapi_compute.py b/nova/wsgi/osapi_compute.py index 7f4de03b0715..12403b746ebb 100644 --- a/nova/wsgi/osapi_compute.py +++ b/nova/wsgi/osapi_compute.py @@ -19,6 +19,7 @@ from nova.api.openstack import wsgi_app NAME = "osapi_compute" application = None -with threading.Lock(): +lock = threading.Lock() +with lock: if application is None: application = wsgi_app.init_application(NAME)