Merge pull request #55845 from ClickHouse/changelog-fix

Fix caching objects in pygithub, and changelogs
This commit is contained in:
Mikhail f. Shiryaev 2023-10-19 20:04:13 +02:00 committed by GitHub
commit 7878204828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,7 +127,7 @@ class GitHub(github.Github):
label="release",
)
def sleep_on_rate_limit(self):
def sleep_on_rate_limit(self) -> None:
for limit, data in self.get_rate_limit().raw_data.items():
if data["remaining"] == 0:
sleep_time = data["reset"] - int(datetime.now().timestamp()) + 1
@ -199,13 +199,13 @@ class GitHub(github.Github):
# We don't want the cache_updated being always old,
# for example in cases when the user is not updated for ages
cache_updated = max(
datetime.fromtimestamp(cache_file.stat().st_mtime), cached_obj.updated_at
cache_file.stat().st_mtime, cached_obj.updated_at.timestamp()
)
if obj_updated_at is None:
# When we don't know about the object is updated or not,
# we update it once per hour
obj_updated_at = datetime.now() - timedelta(hours=1)
if obj_updated_at <= cache_updated:
if obj_updated_at.timestamp() <= cache_updated:
return True, cached_obj
return False, cached_obj