fix: scanner - prevent stuck when exceed rate limit

This commit is contained in:
Dr.Lt.Data 2024-04-02 20:52:59 +09:00
parent 337f2fd738
commit 4120138e06

View File

@ -5,6 +5,7 @@ import json
from git import Repo from git import Repo
from torchvision.datasets.utils import download_url from torchvision.datasets.utils import download_url
import concurrent import concurrent
import datetime
builtin_nodes = set() builtin_nodes = set()
@ -217,9 +218,6 @@ def update_custom_nodes():
git_url_titles_preemptions = get_git_urls_from_json('custom-node-list.json') git_url_titles_preemptions = get_git_urls_from_json('custom-node-list.json')
def process_git_url_title(url, title, preemptions, node_pattern): def process_git_url_title(url, title, preemptions, node_pattern):
if 'Jovimetrix' in title:
pass
name = os.path.basename(url) name = os.path.basename(url)
if name.endswith(".git"): if name.endswith(".git"):
name = name[:-4] name = name[:-4]
@ -238,6 +236,8 @@ def update_custom_nodes():
github_stats = json.load(file) github_stats = json.load(file)
except FileNotFoundError: except FileNotFoundError:
pass pass
if g.rate_limiting_resettime-datetime.datetime.now().timestamp() <= 0:
for url, title, preemptions, node_pattern in git_url_titles_preemptions: for url, title, preemptions, node_pattern in git_url_titles_preemptions:
if url not in github_stats: if url not in github_stats:
# Parsing the URL # Parsing the URL
@ -262,6 +262,7 @@ def update_custom_nodes():
with open(GITHUB_STATS_FILENAME, 'w', encoding='utf-8') as file: with open(GITHUB_STATS_FILENAME, 'w', encoding='utf-8') as file:
json.dump(github_stats, file, ensure_ascii=False, indent=4) json.dump(github_stats, file, ensure_ascii=False, indent=4)
print(f"Successfully written to {GITHUB_STATS_FILENAME}, removing {GITHUB_STATS_CACHE_FILENAME}.") print(f"Successfully written to {GITHUB_STATS_FILENAME}, removing {GITHUB_STATS_CACHE_FILENAME}.")
try: try:
os.remove(GITHUB_STATS_CACHE_FILENAME) # This cache file is just for avoiding failure of GitHub API fetch, so it is safe to remove. os.remove(GITHUB_STATS_CACHE_FILENAME) # This cache file is just for avoiding failure of GitHub API fetch, so it is safe to remove.