@@ -359,7 +359,17 @@ Base.@kwdef struct HeadInfo
359359 last_modified:: Union{String, Nothing}
360360end
361361
362+ # We call this function before hitting an upstream server.
363+ # By default, it is a sleep(0), but we can make this user-configurable.
364+ # So that way, if a user is using a mirror that has rate-limits, they can configure this
365+ # to help them stay under the limits.
366+ function my_sleep ()
367+ sleep (0 )
368+ return nothing
369+ end
370+
362371function get_new_headinfo_for_url (url:: URI )
372+ my_sleep ()
363373 response = HTTP. head (url; status_exception = false )
364374 status = response. status
365375 if status != 200
@@ -428,10 +438,16 @@ function get_tags()
428438 @info (" Probing for tag list..." )
429439 request_path = " repos/JuliaLang/julia/git/refs/tags"
430440 token = strip (get (ENV , " GITHUB_TOKEN" , " " ))
441+
442+
443+
431444 if ! isempty (token)
432445 # The user provided GITHUB_TOKEN, so we use that to authenticate to GitHub API.
433446 # We don't cache this result - this ensures we get the freshest data.
434447 auth = GitHub. authenticate (token)
448+
449+ # Note: GitHub.jl now has rate-limit support built-in.
450+ # So we don't call my_sleep() here.
435451 return GitHub. gh_get_json (GitHub. DEFAULT_API, " /$request_path " ; auth)
436452 else
437453 # The user didn't provide GITHUB_TOKEN, so we have to make an unauthenticated call
@@ -549,6 +565,7 @@ function main!(content::OutputJsonContent, cfg::Config)
549565 number_urls_tried += 1
550566
551567 # This will download the file to a tempfile
568+ my_sleep ()
552569 filepath = Downloads. download (string (url))
553570
554571 if filesize (filepath) == 0
@@ -643,6 +660,7 @@ function main!(content::OutputJsonContent, cfg::Config)
643660 asc_filename = basename (string (asc_url))
644661 @debug " Downloading $asc_filename "
645662 try
663+ my_sleep ()
646664 asc_filepath = Downloads. download (string (asc_url))
647665 asc_signature = String (read (asc_filepath))
648666 rm (asc_filepath)
0 commit comments