diff --git a/src/auth.nim b/src/auth.nim index f2b82f925..00758eb49 100644 --- a/src/auth.nim +++ b/src/auth.nim @@ -5,7 +5,7 @@ import experimental/parser/guestaccount # max requests at a time per account to avoid race conditions const - maxConcurrentReqs = 2 + maxConcurrentReqs = 5 dayInSeconds = 24 * 60 * 60 apiMaxReqs: Table[Api, int] = { Api.search: 50, @@ -203,7 +203,7 @@ proc initAccountPool*(cfg: Config; path: string) = quit 1 let accountsPrePurge = accountPool.len - accountPool.keepItIf(not it.hasExpired) + #accountPool.keepItIf(not it.hasExpired) log "Successfully added ", accountPool.len, " valid accounts." if accountsPrePurge > accountPool.len: diff --git a/src/http_pool.nim b/src/http_pool.nim index 664e9a6e1..7c48c43f6 100644 --- a/src/http_pool.nim +++ b/src/http_pool.nim @@ -18,6 +18,12 @@ proc setHttpProxy*(url: string; auth: string) = else: proxy = nil +proc clear*(pool: HttpPool) = + for client in pool.conns: + try: client.close() + except: discard + pool.conns.setLen(0) + proc release*(pool: HttpPool; client: AsyncHttpClient; badClient=false) = if pool.conns.len >= maxConns or badClient: try: client.close() @@ -42,6 +48,7 @@ template use*(pool: HttpPool; heads: HttpHeaders; body: untyped): untyped = except BadClientError, ProtocolError: # Twitter returned 503 or closed the connection, we need a new client pool.release(c, true) + pool.clear() badClient = false c = pool.acquire(heads) body