Skip to content

Commit 80adf57

Browse files
authored
Merge pull request #397 from FoamyGuy/attempt_fix_actions_hang
Attempt to fix actions hang
2 parents 761055f + 2a9c35e commit 80adf57

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

adabot/github_requests.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ def request(method, url, **kwargs):
103103
logging.warning("Rate Limit will reset at: %s", rate_limit_reset)
104104
reset_diff = rate_limit_reset - datetime.datetime.now()
105105

106-
logging.info("Sleeping %s seconds", reset_diff.seconds)
107-
time.sleep(reset_diff.seconds + 1)
106+
# wait a full extra 60 seconds to avoid time collision
107+
logging.info("Sleeping %s seconds", reset_diff.seconds + 60)
108+
time.sleep(reset_diff.seconds + 60)
108109

109110
return response
110111

adabot/lib/bundle_announcer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import github as pygithub
2020
import parse
2121

22+
from adabot.lib.common_funcs import MAXIMUM_RATE_LIMIT_DELAY
23+
2224
GH_INTERFACE = pygithub.Github(os.environ.get("ADABOT_GITHUB_ACCESS_TOKEN"))
2325

2426
RepoResult: TypeAlias = Tuple[str, str]
@@ -82,7 +84,7 @@ def get_bundle_updates(full_repo_name: str) -> Tuple[Set[RepoResult], Set[RepoRe
8284
core_rate_limit_reset = GH_INTERFACE.get_rate_limit().core.reset
8385
sleep_time = core_rate_limit_reset - datetime.datetime.utcnow()
8486
logging.warning("Rate Limit will reset at: %s", core_rate_limit_reset)
85-
time.sleep(sleep_time.seconds)
87+
time.sleep(min(sleep_time.seconds, MAXIMUM_RATE_LIMIT_DELAY))
8688
continue
8789
except pygithub.GithubException:
8890
# Secrets may not be available or error occurred - just skip

adabot/lib/circuitpython_library_validators.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ def validate_readthedocs(self, repo):
935935
core_rate_limit_reset = GH_INTERFACE.get_rate_limit().core.reset
936936
sleep_time = core_rate_limit_reset - datetime.datetime.utcnow()
937937
logging.warning("Rate Limit will reset at: %s", core_rate_limit_reset)
938-
time.sleep(sleep_time.seconds)
938+
time.sleep(
939+
min(sleep_time.seconds, common_funcs.MAXIMUM_RATE_LIMIT_DELAY)
940+
)
939941
continue
940942
except pygithub.GithubException:
941943
errors.append(ERROR_RTD_FAILED_TO_LOAD_BUILD_STATUS_GH_NONLIMITED)
@@ -1295,7 +1297,9 @@ def validate_actions_state(self, repo):
12951297
core_rate_limit_reset = GH_INTERFACE.get_rate_limit().core.reset
12961298
sleep_time = core_rate_limit_reset - datetime.datetime.utcnow()
12971299
logging.warning("Rate Limit will reset at: %s", core_rate_limit_reset)
1298-
time.sleep(sleep_time.seconds)
1300+
time.sleep(
1301+
min(sleep_time.seconds, common_funcs.MAXIMUM_RATE_LIMIT_DELAY)
1302+
)
12991303

13001304
def validate_default_branch(self, repo):
13011305
"""Makes sure that the default branch is main"""

adabot/lib/common_funcs.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
CORE_REPO_URL = "/repos/adafruit/circuitpython"
1919

20+
MAXIMUM_RATE_LIMIT_DELAY = 62 * 60 # 62 minutes
21+
2022

2123
def parse_gitmodules(input_text):
2224
# pylint: disable=anomalous-backslash-in-string

0 commit comments

Comments
 (0)