Skip to content

Commit

Permalink
Update runner.py to avoid ratelimit on github
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekokatt committed Aug 10, 2020
1 parent 3b54631 commit acc8021
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions runner.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
@dataclasses.dataclass()
class Config:
webhook_url: str
period: float = 60
period: float = 300
threads: int = os.cpu_count() or 1
api_url: str = "https://api.github.com/repos/discord/discord-api-docs/commits"
params: typing.Dict[str, str] = dataclasses.field(default_factory=lambda: {"sha": "master"})
@@ -47,7 +47,7 @@ class Config:
config = dacite.from_dict(Config, yaml.safe_load(fp))


while True:
def poll() -> None:
params = {**config.params, "since": last_update}

with requests.get(config.api_url, params=params) as resp:
@@ -113,4 +113,13 @@ class Config:
else:
logging.info("No new commits, going to sleep")

time.sleep(config.period)

i = 0
while True:
if i:
time.sleep(config.period)

try:
poll()
finally:
i += 1

0 comments on commit acc8021

Please sign in to comment.