Skip to content

Commit

Permalink
Have a sleep if 409 on push to gh
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoWill committed Mar 18, 2024
1 parent 2c10181 commit cf0ce25
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions polling_stations/apps/file_uploads/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from datetime import timedelta

from commitment import GitHubClient, GitHubCredentials
Expand Down Expand Up @@ -255,12 +256,25 @@ def make_pull_request(self):
else:
raise e

client.push_file(
content=self.import_script,
filename=self.gss.import_script_path,
message=self.pr_title,
branch=self.branch_name,
)
try:
client.push_file(
content=self.import_script,
filename=self.gss.import_script_path,
message=self.pr_title,
branch=self.branch_name,
)
except HTTPError as e:
status_code = e.response.status_code
if status_code == 409:
time.sleep(10)
client.push_file(
content=self.import_script,
filename=self.gss.import_script_path,
message=self.pr_title,
branch=self.branch_name,
)
else:
raise e

try:
client.open_pull_request(
Expand Down

0 comments on commit cf0ce25

Please sign in to comment.