@@ -66,6 +66,9 @@ function safe_tryparse(args...)
6666 end
6767end
6868
69+ # convert a numeric number of seconds to a canonicalized object for printing
70+ to_canon (val_seconds:: Number ) = Dates. canonicalize (Nanosecond (round (Int, val_seconds* 1e9 )))
71+
6972"""
7073 github_retry_decision(method::String, resp::Union{HTTP.Response, Nothing}, ex::Union{Exception, Nothing}, exponential_delay::Float64; verbose::Bool=true) -> (should_retry::Bool, sleep_seconds::Float64)
7174
@@ -111,7 +114,7 @@ function github_retry_decision(method::String, resp::Union{HTTP.Response, Nothin
111114 if ex != = nothing
112115 # If there's an exception, check if it's recoverable and if the method is idempotent
113116 if HTTP. RetryRequest. isrecoverable (ex) && HTTP. RetryRequest. isidempotent (method)
114- verbose && @info " GitHub API exception, retrying in $(round (exponential_delay, digits = 1 )) s " method= method exception= ex
117+ verbose && @info " GitHub API exception, retrying in $(to_canon (exponential_delay)) " method= method exception= ex delay_seconds = exponential_delay
115118 return (true , exponential_delay)
116119 end
117120 end
@@ -159,7 +162,7 @@ function github_retry_decision(method::String, resp::Union{HTTP.Response, Nothin
159162 delay_seconds = safe_tryparse (Float64, retry_after)
160163 if delay_seconds != = nothing
161164 delay_seconds = parse (Float64, retry_after)
162- verbose && @info " $msg , retrying in $(round (delay_seconds, digits = 1 )) s " method= method status= status limit= limit remaining= remaining used= used reset= reset_time resource= resource retry_after= retry_after
165+ verbose && @info " $msg , retrying in $(to_canon (delay_seconds)) " method= method status= status limit= limit remaining= remaining used= used reset= reset_time resource= resource retry_after= retry_after delay_seconds = delay_seconds
163166 return (true , delay_seconds)
164167 end
165168
@@ -169,7 +172,7 @@ function github_retry_decision(method::String, resp::Union{HTTP.Response, Nothin
169172 current_time = time ()
170173 if reset_timestamp > current_time
171174 delay_seconds = reset_timestamp - current_time + 1.0
172- verbose && @info " $msg , retrying in $(round (delay_seconds, digits = 1 )) s " method= method status= status limit= limit remaining= remaining used= used reset= reset_time resource= resource retry_after= retry_after
175+ verbose && @info " $msg , retrying in $(to_canon (delay_seconds)) " method= method status= status limit= limit remaining= remaining used= used reset= reset_time resource= resource retry_after= retry_after delay_seconds = delay_seconds
173176 return (true , delay_seconds)
174177 end
175178 end
@@ -179,7 +182,8 @@ function github_retry_decision(method::String, resp::Union{HTTP.Response, Nothin
179182 # Fall back to exponential backoff
180183 delay_seconds = is_secondary_rate_limit ? max (60.0 , exponential_delay) : exponential_delay
181184
182- verbose && @info " $msg , retrying in $(round (delay_seconds, digits= 1 )) s" method= method status= status
185+ # Fall back to exponential backoff
186+ verbose && @info " $msg , retrying in $(to_canon (delay_seconds)) " method= method status= status delay_seconds= delay_seconds
183187
184188 return (true , delay_seconds)
185189end
0 commit comments