Closed caioluccas closed 2 years ago
Again we need the full repro code to understand.
Are you calling close()
after the request is done?,
theres a refactor pending to not need the call to close()
anymore, but is still to be done.
No im not calling close(), its just crashing in 396 request for no reason and its not returning a error
this is the code:
while task_ended == False:
for token in alt_tokens:
headers = {"Authorization": "Bearer " + token}
check_availability = requests.get(endpoint, http_headers=headers)
if check_availability.status_code == 200:
count = count + 1
print(f'[League Sniper] Target Nick: {target_nick} | Requests: {count} | Response: {check_availability.text} | Currency: {currency.upper()}')
if check_availability.text == "true":
buy = req.post(change_nick_url, json=payload, headers=main_headers)
if buy.status_code == 200:
os.system('cls')
print(ascii.league_sniper_ascii + "\n")
print(f'[League Sniper] You have been sniped {target_nick} in 0 requests. ({username}:{passw})')
os.system('pause')
task_ended = True
break
else:
print(check_availability.status_code)
You have to call close_client()
after the request,
it is failing because you are opening too much sockets too fast, the OS is the one killing it.
This is not ideal, in the future it will not be needed, but until then you have to call faster_than_requests.close_client()
.
ok, i will try, thanks man
i tried using it in two different ways and now it's just closing after the first request
first way:
while task_ended == False:
for token in alt_tokens:
headers = [("Authorization", "Bearer " + token)]
check_availability = requests.get(endpoint, http_headers=headers)
if check_availability[2] == "200 OK":
count = count + 1
print(f'[League Sniper] Target Nick: {target_nick} | Requests: {count} | Response: {check_availability[0]} | Currency: {currency.upper()}')
requests.close_client()
if check_availability[0] == "true":
buy = requests.post(change_nick_url, body=payload, http_headers=main_headers)
if buy[2] == "200 OK":
os.system('cls')
print(ascii.league_sniper_ascii + "\n")
print(f'[League Sniper] You have been sniped {target_nick} in {count} requests. ({username}:{passw})')
os.system('pause')
task_ended = True
break
else:
print(check_availability[2])
second way:
while task_ended == False:
for token in alt_tokens:
headers = [("Authorization", "Bearer " + token)]
check_availability = requests.get(endpoint, http_headers=headers)
requests.close_client()
if check_availability[2] == "200 OK":
count = count + 1
print(f'[League Sniper] Target Nick: {target_nick} | Requests: {count} | Response: {check_availability[0]} | Currency: {currency.upper()}')
if check_availability[0] == "true":
buy = requests.post(change_nick_url, body=payload, http_headers=main_headers)
if buy[2] == "200 OK":
os.system('cls')
print(ascii.league_sniper_ascii + "\n")
print(f'[League Sniper] You have been sniped {target_nick} in {count} requests. ({username}:{passw})')
os.system('pause')
task_ended = True
break
else:
print(check_availability[2])
The second way looks okey, but you have to call it for the post()
too.
the script crashes before the post request
after the get request in 4 line the script closes
for some reason when I use faster than requests to send many requests to a url in the 396 request the script closes and no error is showing, when i use the request lib it works normally. is there any reason?