Skip to content

Commit 15d9b57

Browse files
committed
Add some rate limiting to ensure that we don't get rejected by GitHub
1 parent 117ebde commit 15d9b57

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/import_backends.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pathlib
22
import textwrap
3+
import time
34
import urllib.parse
45
from getpass import getpass
56
from typing import TYPE_CHECKING, Dict, List, Sequence, cast
@@ -215,6 +216,14 @@ def labels(self, ticket: Ticket) -> List[github.Label.Label]:
215216
return labels
216217

217218
def submit(self, ticket: Ticket) -> int:
219+
# GitHub are somewhat strict on their API rate limits, in particular
220+
# their "secondary rate limits" encourage a generouse (> 1s) gap between
221+
# `POST` requests. Frustratingly these appear to be separate from the
222+
# primary rate limits which can be queried via the API. Manual testing
223+
# indicates that ~2s isn't always sufficient, so err on the side of a
224+
# larger gap for better reliability.
225+
time.sleep(5)
226+
218227
issue = self.repo.create_issue(
219228
ticket.summary,
220229
self.description_text(ticket),

0 commit comments

Comments
 (0)