question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

None in the response when the URLs list is over 100

See original GitHub issue

Hi,

I am seeing a strange behavior in the response when the URLs list is over 100 or more items. Most of the responses I get from the grequests are of None.

I’ve seen the similar issue that was raised by another member https://www.reddit.com/r/Python/comments/4ifmat/using_grequests_after_a_certain_amount_of/

Here are the few things I’ve tried:

  • Used one proxy per URL but still None response for some URLs.
  • Iterated the None URLs with the requests library and I am getting the 200 response code.
  • Created a chunk of URLs, 20 URLs per map requests and it brought the 200 response for 16 urls and 4 URLs None Response.

Is there a bug in the library or something I need to fix on my end?

Below is a code used:

HEADERS_DEFAULT = {
    "Accept-Language": "en-US,en;q=0.5",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Connection": "keep-alive"
}

cleaned_products_list = [a list of URLs I used here.]
products_rs = set()
 for u in cleaned_products_list:
    products_rs.add(grequests.get(
                             u, proxies=random.choice(PROXIES_LIST), 
                             headers=HEADERS_DEFAULT))

response_list = grequests.map(products_rs)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
willhaslamcommented, Feb 24, 2017

@azhard4int I’ve managed to solve my None responses by passing the errors to an error handler. grequests returned None if the request errors, which in my case is SSL errors.

e.g.

def exception_handler(request, exception):
    print(exception)

grequests.map(unsent_requests, exception_handler=exception_handler)
0reactions
spyoungtechcommented, Jan 4, 2018

@Jaronloch2 exception_handler is an argument to map not get.

>>> req = grequests.get('https://httpbin.org', exception_handler='foo')
>>> req.send()
>>> req.exception
TypeError("request() got an unexpected keyword argument 'exception_handler'",)

This would cause the behavior you describe. Please look more carefully at the previous comments.

That said, I don’t think this is a direct issue with grequests. Have tested extensively with sending very large numbers of requests. You’re likely running into a different underlying issue.

If this is still an issue, at a minimum, please provide the underlying exception using the method described by @willhaslam

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >
List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >
HTTP/1.1: Status Code Definitions
A client MUST be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does...
Read more >
A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >
urllib.request — Extensible library for opening URLs — Python ...
urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, ... See urllib.response.addinfourl for more detail on these properties.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found