Skip to content

Commit

Permalink
Sleep even less between polling for MRs
Browse files Browse the repository at this point in the history
The logic is: we want to sleep at least 30 secs after iterating over all
projects (both so that people have a chance to undo accidental assignments to
marge and to not poll like crazy when nothing is happening to the repo). If
there are many projects, the current system sleeps too long, though. Let's just
sleep one sec between each by default and then make up the difference to the 30s
afterwards.
  • Loading branch information
Alexander Schmolck committed Jan 10, 2018
1 parent d5e588c commit 9f70c5c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions marge/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def api(self):
return self._api

def _run(self, repo_manager):
time_to_sleep_between_projects_in_secs = 1
min_time_to_sleep_after_iterating_all_projects_in_secs = 30
while True:
log.info('Finding out my current projects...')
my_projects = Project.fetch_all_mine(self._api)
Expand Down Expand Up @@ -104,12 +106,15 @@ def _run(self, repo_manager):
options=self._config.merge_opts,
)
merge_job.execute()
time_to_sleep_in_secs = 5
else:
log.info('Nothing to merge at this point...')
time_to_sleep_in_secs = 30
log.info('Sleeping for %s seconds...', time_to_sleep_in_secs)
time.sleep(time_to_sleep_in_secs)
time.sleep(time_to_sleep_between_projects_in_secs)
big_sleep = max(0,
min_time_to_sleep_after_iterating_all_projects_in_secs -
time_to_sleep_between_projects_in_secs * len(filtered_projects))
log.info('Sleeping for %s seconds...', big_sleep)
time.sleep(big_sleep)




Expand Down

0 comments on commit 9f70c5c

Please sign in to comment.