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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2025-05-08 12:38:28 +01:00
parent a106f25e8e
commit 023be4f561
2 changed files with 4 additions and 2 deletions

View File

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

View File

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