Skip to content

Commit

Permalink
Fix rate limit handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Feb 12, 2025
1 parent 7702576 commit 5be3773
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/auth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import experimental/parser/session

# max requests at a time per session to avoid race conditions
const
maxConcurrentReqs = 3
maxConcurrentReqs = 2
dayInSeconds = 24 * 60 * 60
apiMaxReqs: Table[Api, int] = {
Api.search: 50,
Expand Down Expand Up @@ -130,8 +130,9 @@ proc isLimited(session: Session; api: Api): bool =
if (epochTime().int - session.limitedAt) > dayInSeconds:
session.limited = false
log "resetting limit: ", session.id
else:
return false
else:
return true

if api in session.apis:
let limit = session.apis[api]
Expand Down

0 comments on commit 5be3773

Please sign in to comment.