@@ -171,6 +171,7 @@ def main() -> int:
171171
172172 start = time .monotonic ()
173173 announced_waiting_for_run = False
174+ last_error : str | None = None
174175 last_status : str | None = None
175176 target_run_id = args .run_id
176177
@@ -180,32 +181,42 @@ def main() -> int:
180181 return 124
181182
182183 run : dict [str , Any ] | None
183- if target_run_id is not None :
184- run = fetch_run_by_id (args .repo , target_run_id )
185- else :
186- run = find_matching_run (
187- args .repo ,
188- commit = args .commit ,
189- branch = args .branch ,
190- workflow = args .workflow ,
191- event = args .event ,
192- )
193- if run is None :
194- if not announced_waiting_for_run :
195- print (
196- "waiting for matching run: repo={repo} commit={commit} branch={branch} workflow={workflow} event={event}" .format (
197- repo = args .repo ,
198- commit = args .commit or "" ,
199- branch = args .branch or "" ,
200- workflow = args .workflow or "" ,
201- event = args .event or "" ,
202- ),
203- flush = True ,
204- )
205- announced_waiting_for_run = True
206- time .sleep (args .interval )
207- continue
208- target_run_id = int (run ["databaseId" ])
184+ try :
185+ if target_run_id is not None :
186+ run = fetch_run_by_id (args .repo , target_run_id )
187+ else :
188+ run = find_matching_run (
189+ args .repo ,
190+ commit = args .commit ,
191+ branch = args .branch ,
192+ workflow = args .workflow ,
193+ event = args .event ,
194+ )
195+ if run is None :
196+ if not announced_waiting_for_run :
197+ print (
198+ "waiting for matching run: repo={repo} commit={commit} branch={branch} workflow={workflow} event={event}" .format (
199+ repo = args .repo ,
200+ commit = args .commit or "" ,
201+ branch = args .branch or "" ,
202+ workflow = args .workflow or "" ,
203+ event = args .event or "" ,
204+ ),
205+ flush = True ,
206+ )
207+ announced_waiting_for_run = True
208+ time .sleep (args .interval )
209+ continue
210+ target_run_id = int (run ["databaseId" ])
211+ except RuntimeError as exc :
212+ message = str (exc )
213+ if message != last_error :
214+ print (f"transient gh error, retrying: { message } " , file = sys .stderr , flush = True )
215+ last_error = message
216+ time .sleep (args .interval )
217+ continue
218+
219+ last_error = None
209220
210221 status = run ["status" ]
211222 if status != last_status :
0 commit comments