Fix global variable placement

This commit is contained in:
James Campbell 2025-06-04 12:49:35 -04:00
parent cfe01eb63e
commit 8fe81e3ab3
Signed by: james
GPG Key ID: 2287C33A40DC906A

View File

@ -518,7 +518,6 @@ def parse_version_rss(raw_rss, release):
This sets these global variables:
latest_version
latest_version_next_check
release_supported
It is expected that the caller already holds the latest_version_lock lock.
@ -528,7 +527,6 @@ def parse_version_rss(raw_rss, release):
release: The PostgreSQL release we care about (ex: 9.2, 14)
"""
global latest_version
global latest_version_next_check
global release_supported
# Regular expressions for parsing the RSS document
@ -583,6 +581,8 @@ def get_latest_version():
Get the latest supported version of the major PostgreSQL release running on the server being monitored.
"""
global latest_version_next_check
# If we don't know the latest version or it's past the recheck time, get the
# version from the PostgreSQL RSS feed. Only one thread needs to do this, so
# they all try to grab the lock, and then make sure nobody else beat them to it.
@ -705,7 +705,10 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
self._reply(
200,
json.dumps(
{"latest": latest_version, "supported": 1 if release_supported else 0}
{
"latest": latest_version,
"supported": 1 if release_supported else 0,
}
),
)
except LatestVersionCheckError as e: