File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
api/ruby/find-inactive-members Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,23 @@ def calculate_dynamic_delay
66
66
def throttle_request
67
67
current_time = Time . now
68
68
69
+ # Check if rate limit is critically low and pause until reset if needed
70
+ if @github_rate_limit_remaining && @github_rate_limit_remaining < 50 && @github_rate_limit_reset
71
+ time_until_reset = [ @github_rate_limit_reset - current_time . to_i , 0 ] . max
72
+ if time_until_reset > 0
73
+ pause_time = time_until_reset + 5 # Add 5 second buffer
74
+ minutes = ( pause_time / 60.0 ) . round ( 1 )
75
+ $stderr. print "\n ⚠️ RATE LIMIT LOW: Only #{ @github_rate_limit_remaining } requests remaining!\n "
76
+ $stderr. print "⏸️ Pausing for #{ minutes } minutes until rate limit resets (#{ pause_time } seconds total)\n "
77
+ $stderr. print "⏰ Will resume at approximately #{ ( Time . now + pause_time ) . strftime ( '%H:%M:%S' ) } \n \n "
78
+ sleep ( pause_time )
79
+
80
+ # Reset our tracking after the pause
81
+ @github_rate_limit_remaining = nil # Will be updated on next response
82
+ @github_rate_limit_reset = nil
83
+ end
84
+ end
85
+
69
86
# Reset counter if we've moved to a new hour (sliding window)
70
87
if current_time - @hour_start_time >= 3600
71
88
@request_count = 0
You can’t perform that action at this time.
0 commit comments