Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
HTTPConnection request hangs when no connection to internet
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
FM  
View profile  
 More options Aug 28 2012, 11:41 am
From: FM <fmarti...@gmail.com>
Date: Tue, 28 Aug 2012 08:41:06 -0700 (PDT)
Local: Tues, Aug 28 2012 11:41 am
Subject: HTTPConnection request hangs when no connection to internet

I am using gevent 0.13.6, greenlet 0.3.1.

Without patching, python httplib throws "socket.gaierror: [Errno 11004]
getaddrinfo failed", however when patching with gevent it hangs on the
"request" call

Is there anything I can do to avoid this behavior?

Please find sample code below.

import gevent.monkey
gevent.monkey.patch_socket(True, True)
gevent.monkey.patch_select(True)
gevent.monkey.patch_ssl()
gevent.monkey.patch_httplib()

import httplib
url = 'www.google.com'
conn = httplib.HTTPConnection(url, timeout=2)
headers = {"Content-type": "application/json"}
print 'before conn.request'
conn.request("GET", url,headers=headers)
print 'after conn.request'
response = conn.getresponse()
if response.status == 200:
    data = response.read()
    print data
else:
    raise Exception("HTTP %d %s"%(response.status,response.msg))
conn.close()

# Output when patching
C:\Python27\python.exe C:/Development/python/http/hang.py
before conn.request
Internal error in evhttp

# Output when using regular python hhtplib
#C:\Python27\python.exe C:/Development/python/http/hang.py
#before conn.request
#Traceback (most recent call last):
#  File "C:/Development/python/http/hang.py", line 14, in <module>
#    conn.request("GET", url,headers=headers)
#  File "C:\Python27\lib\httplib.py", line 941, in request
#    self._send_request(method, url, body, headers)
#  File "C:\Python27\lib\httplib.py", line 975, in _send_request
#    self.endheaders(body)
#  File "C:\Python27\lib\httplib.py", line 937, in endheaders
#    self._send_output(message_body)
#  File "C:\Python27\lib\httplib.py", line 797, in _send_output
#    self.send(msg)
#  File "C:\Python27\lib\httplib.py", line 759, in send
#    self.connect()
#  File "C:\Python27\lib\httplib.py", line 740, in connect
#    self.timeout, self.source_address)
#  File "C:\Python27\lib\socket.py", line 553, in create_connection
#    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
#socket.gaierror: [Errno 11004] getaddrinfo failed
#
#Process finished with exit code 1


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
FM  
View profile  
 More options Aug 29 2012, 9:04 am
From: FM <fmarti...@gmail.com>
Date: Wed, 29 Aug 2012 06:04:41 -0700 (PDT)
Local: Wed, Aug 29 2012 9:04 am
Subject: Re: HTTPConnection request hangs when no connection to internet

I forgot to add, it keeps on hanging once connection is restored.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »