0

Is there anyway to disable grequests's logging to console? My applications returns error in the requests part:

Timeout: (<requests.packages.urllib3.connectionpool.HTTPConnectionPool object at 0x10daa1a50>, 'Connection to 116.231.213.50 timed out. (connect timeout=5)')
<Greenlet at 0x10d92bf50: <bound method AsyncRequest.send of <grequests.AsyncRequest object at 0x10da97990>>(stream=False)> failed with Timeout

I found this to disable requests's logging but no luck with the grequests.

Community
  • 1
  • 1
AliBZ
  • 4,039
  • 12
  • 45
  • 67

1 Answers1

1

If you used the approach in your link to disable requests logging (e.g. logging.getLogger("requests").setLevel(logging.CRITICAL)) then it should work for grequests too. Have you tried it? If you have and it still doesn't behave as you would like, configure logging to show logger names (e.g. via basicConfig using %(name)s in the format string) and you should see exactly which loggers are producing the messages, and you can then silence them using the same approach as for the requests logger.

Vinay Sajip
  • 95,872
  • 14
  • 179
  • 191
  • I did what you suggested, but still no luck. Now, I am sure that it doesn't use logging. It just prints the error on the console. How can I disable that? – AliBZ Oct 23 '13 at 23:17
  • You know the problem is I can not even catch the exceptions coming from requests like "proxy error" or "timeout error". If I could catch them, I could prevent them from printing on console. – AliBZ Oct 24 '13 at 00:19