i tried my hardest to ratelimit myself locally and it didnt work so this code fixes ratelimit issues :)
This commit is contained in:
parent
c9b2e94ba9
commit
be4c83bfb0
1 changed files with 3 additions and 3 deletions
|
@ -125,7 +125,7 @@ template fetchImpl(result, additional_headers, fetchBody) {.dirty.} =
|
|||
except OSError as e:
|
||||
raise e
|
||||
except Exception as e:
|
||||
#echo "error: ", e.name, ", msg: ", e.msg, ", token: ", token[], ", url: ", url
|
||||
echo "error: ", e.name, ", msg: ", e.msg, ", url: ", url
|
||||
#if "length" notin e.msg and "descriptor" notin e.msg:
|
||||
#release(token, invalid=true)
|
||||
raise rateLimitError()
|
||||
|
@ -138,7 +138,7 @@ template retry(bod) =
|
|||
bod
|
||||
|
||||
proc fetch*(url: Uri; api: Api; additional_headers: HttpHeaders = newHttpHeaders()): Future[JsonNode] {.async.} =
|
||||
retry:
|
||||
#retry:
|
||||
var body: string
|
||||
fetchImpl(body, additional_headers):
|
||||
if body.startsWith('{') or body.startsWith('['):
|
||||
|
@ -156,7 +156,7 @@ proc fetch*(url: Uri; api: Api; additional_headers: HttpHeaders = newHttpHeaders
|
|||
raise rateLimitError()
|
||||
|
||||
proc fetchRaw*(url: Uri; api: Api; additional_headers: HttpHeaders = newHttpHeaders()): Future[string] {.async.} =
|
||||
retry:
|
||||
#retry:
|
||||
fetchImpl(result, additional_headers):
|
||||
if not (result.startsWith('{') or result.startsWith('[')):
|
||||
echo resp.status, ": ", result, " --- url: ", url
|
||||
|
|
Loading…
Reference in a new issue