{"issue":{"title":"name resolution failures under gevent","user":{"login":"clearclaw","id":1278881,"url":"https://api.github.com/users/clearclaw","gravatar_id":"db32238d5eebf878622c8bd2770a7d0e","avatar_url":"https://secure.gravatar.com/avatar/db32238d5eebf878622c8bd2770a7d0e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-12-22T00:40:57Z","milestone":null,"labels":[],"state":"open","updated_at":"2011-12-27T21:10:24Z","id":2631585,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"closed_at":null,"html_url":"https://github.com/benoitc/gunicorn/issues/289","body":"    $ python26 -c \"from gevent.core import *; print get_method(), get_version()\"\r\n    epoll 1.4.13-stable\r\n\r\n    $ rpm -qa | fgrep gevent\r\n    python-gevent-1.0a3-95699\r\n\r\n    $ python26 -c \"import gevent; from gevent import socket; from gevent.dns import resolve_ipv4; print socket.gethostbyname ('google.com'); print resolve_ipv4; resolve_ipv4 ('google.com')\"\r\n    74.125.224.240\r\n    <function resolve_ipv4 at 0x2b3cdbd7ef50>\r\n    Traceback (most recent call last):\r\n      File \"<string>\", line 1, in <module>\r\n      File \"/usr/lib64/python2.6/site-packages/gevent/dns.py\", line 59, in resolve_ipv4\r\n        raise DNSError(result)\r\n    gevent.dns.DNSError: [Errno 3] name does not exist\r\n\r\nMore simply under Gunicorn this manifests in a WSGI method which attempts to make an outbound HTTP call using urrlib2.  here follows a stack trace of the fault:\r\n\r\n    ssagent[15076].print_exc_plus(261): CRITICAL Traceback (most recent call last):\r\n      File \"/ysi/apps/a-agent/aagent_upload.py\", line 254, in POST\r\n        conf[\"POSTBACK_RETRIES\"])\r\n      File \"/ysi/apps/a-agent/aagent_upload.py\", line 125, in do_callbacks\r\n        s)\r\n      File \"/usr/lib/python2.6/site-packages/ssagent.py\", line 123, in encrypt_token\r\n        tree = s.do ()\r\n      File \"/usr/lib/python2.6/site-packages/ssagent.py\", line 72, in do\r\n        rc = urllib2.urlopen (req)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 126, in urlopen\r\n        return _opener.open(url, data, timeout)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 391, in open\r\n        response = self._open(req, data)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 409, in _open\r\n        '_open', req)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 369, in _call_chain\r\n        result = func(*args)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 1161, in http_open\r\n        return self.do_open(httplib.HTTPConnection, req)\r\n      File \"/usr/lib64/python2.6/urllib2.py\", line 1136, in do_open\r\n        raise URLError(err)\r\n    URLError: <urlopen error [Errno 3] name does not exist>\r\n    \r\n    ssagent[15076].print_exc_plus(262): CRITICAL Locals by frame, innermost last (first 100 characters):\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame POST in /ysi/apps/a-agent/aagent_upload.py at line 284\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL               status = <aagent_upload.TransferStatus instance at 0x18b6e098>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL          file_target = /shared/silo/094/0ec/d5848b9e-e618-4ae8-b46b-03a5987cf26e.00000000000000000001\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                   qs = {'id': '393183984', 'op': 'xmlupload'}\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                    e = <urlopen error [Errno 3] name does not exist>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 ufid = d5848b9e-e618-4ae8-b46b-03a5987cf26e.00000000000000000001\r\n    ssagent[15076].print_exc_plus(273): CRITICAL          max_filelen = 104857600\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <aagent_upload.AAgent_Upload instance at 0x18b6bc68>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL               offset = 0\r\n    ssagent[15076].print_exc_plus(273): CRITICAL          file_source = /shared/silo/staging/adp-demo/d5848b9e-e618-4ae8-b46b-03a5987cf26e.00000000000000000001\r\n    ssagent[15076].print_exc_plus(273): CRITICAL           disk_limit = 104857600\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 auth = {'ProgressId': '7e66060f-d599-4ff0-8750-8604b170355f', 'ttlBase': '1324512780799', 'ufid': 'd5848b9e\r\n    ssagent[15076].print_exc_plus(273): CRITICAL          max_postlen = 104878080\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                forms = <multipart.MultiDict object at 0x18b72410>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                start = 13245xml = 12781.62\r\n    ssagent[15076].print_exc_plus(273): CRITICAL               length = 2910556\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 conf = {'AUTH_PATH': '/shared/working/a-agent/auth', 'BEANSTALK_HOST': '127.0.0.1', 'BEANSTALK_PORT': '1130\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                   fg = <generator object storagename_generator at 0x18b5af00>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              bufsize = 1048576\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                files = <multipart.MultiDict object at 0x18b72490>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                stage = /shared/silo/staging/adp-demo\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame do_callbacks in /ysi/apps/a-agent/aagent_upload.py at line 153\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL              retries = 10\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                    s = {\"ProgressId\": \"7e66060f-d599-4ff0-8750-8604b170355f\", \"Description\": \"The file successfully uploade\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 auth = {'ProgressId': '7e66060f-d599-4ff0-8750-8604b170355f', 'ttlBase': '1324512780799', 'ufid': 'd5848b9e\r\n    ssagent[15076].print_exc_plus(273): CRITICAL             filename = 1880_rules.pdf\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                forms = <multipart.MultiDict object at 0x18b72410>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 host = https://www.yousendit.com/postback.php\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                    t = {'ProgressId': '7e66060f-d599-4ff0-8750-8604b170355f', 'Description': 'The file successfully uploade\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 conf = {'AUTH_PATH': '/shared/working/a-agent/auth', 'BEANSTALK_HOST': '127.0.0.1', 'BEANSTALK_PORT': '1130\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                   rc = None\r\n    ssagent[15076].print_exc_plus(273): CRITICAL             filesize = 2909321\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame encrypt_token in /usr/lib/python2.6/site-packages/ssagent.py at line 123\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL             endpoint = http://sjclbirbl01.prod.yousendit.com:8090/rbl/YsiEncryption\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                token = {\"ProgressId\": \"7e66060f-d599-4ff0-8750-8604b170355f\", \"Description\": \"The file successfully uploade\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                nsurl = {http://su2}\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                    s = <ssagent.SoapRPC instance at 0x18b6e170>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  api = encodeAESData\r\n    ssagent[15076].print_exc_plus(273): CRITICAL               nsname = su2\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame do in /usr/lib/python2.6/site-packages/ssagent.py at line 72\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  xml = <ns0:Envelope xmlns:ns0=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns1=\"http://www.w3.org/1999/\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <ssagent.SoapRPC instance at 0x18b6e170>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  req = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL               pretty = True\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame urlopen in /usr/lib64/python2.6/urllib2.py at line 126\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  url = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 data = None\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              timeout = <object object at 0x2ae44c3bb0b0>\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame open in /usr/lib64/python2.6/urllib2.py at line 391\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL             protocol = http\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <urllib2.OpenerDirector instance at 0x18b67098>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  req = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL            meth_name = http_request\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              fullurl = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              timeout = <object object at 0x2ae44c3bb0b0>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 meth = <bound method HTTPHandler.do_request_ of <urllib2.HTTPHandler instance at 0x18b67c68>>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 data = None\r\n    ssagent[15076].print_exc_plus(273): CRITICAL            processor = <urllib2.HTTPHandler instance at 0x18b67c68>\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame _open in /usr/lib64/python2.6/urllib2.py at line 409\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 data = None\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <urllib2.OpenerDirector instance at 0x18b67098>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  req = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL             protocol = http\r\n    ssagent[15076].print_exc_plus(273): CRITICAL               result = None\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame _call_chain in /usr/lib64/python2.6/urllib2.py at line 369\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 kind = http\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                chain = {'unknown': [<urllib2.UnknownHandler instance at 0x18b671b8>], 'http': [<urllib2.HTTPHandler instanc\r\n    ssagent[15076].print_exc_plus(273): CRITICAL             handlers = [<urllib2.HTTPHandler instance at 0x18b67c68>]\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <urllib2.OpenerDirector instance at 0x18b67098>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 args = (<urllib2.Request instance at 0x18b6e1b8>,)\r\n    ssagent[15076].print_exc_plus(273): CRITICAL            meth_name = http_open\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              handler = <urllib2.HTTPHandler instance at 0x18b67c68>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 func = <bound method HTTPHandler.http_open of <urllib2.HTTPHandler instance at 0x18b67c68>>\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame http_open in /usr/lib64/python2.6/urllib2.py at line 1161\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <urllib2.HTTPHandler instance at 0x18b67c68>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  req = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(266): CRITICAL Frame do_open in /usr/lib64/python2.6/urllib2.py at line 1136\r\n    \r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  err = [Errno 3] name does not exist\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                    h = <httplib.HTTPConnection instance at 0x18b6e290>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 self = <urllib2.HTTPHandler instance at 0x18b67c68>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                  req = <urllib2.Request instance at 0x18b6e1b8>\r\n    ssagent[15076].print_exc_plus(273): CRITICAL              headers = {'Content-Length': '564', 'Host': 'sjclbirbl01.prod.yousendit.com:8090', 'Content-Type': 'applicatio\r\n    ssagent[15076].print_exc_plus(273): CRITICAL                 host = sjclbirbl01.prod.yousendit.com:8090\r\n    ssagent[15076].print_exc_plus(273): CRITICAL           http_class = httplib.HTTPConnection\r\n\r\nObNote: Values in the stack dump are truncated to ~50 characters to avoid spamming the logs.   \r\n\r\nObAside: I've not yet validated if removing the :PORT from the host also resolves the problem (mostly because I can't in my usecase and the test is a PITA to setup).\r\n\r\nThe key code in ssagent.py that calls urllib2:\r\n\r\n        req = urllib2.Request (self.url,\r\n                               headers = {\"Content-Type\" : \"application/soap+xml\"},\r\n                               data = xml)\r\n        rc = urllib2.urlopen (req)\r\n","number":289,"url":"https://api.github.com/repos/benoitc/gunicorn/issues/289","comments":3,"assignee":null},"comment":{"user":{"login":"clearclaw","id":1278881,"url":"https://api.github.com/users/clearclaw","gravatar_id":"db32238d5eebf878622c8bd2770a7d0e","avatar_url":"https://secure.gravatar.com/avatar/db32238d5eebf878622c8bd2770a7d0e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-12-27T21:10:24Z","updated_at":"2011-12-27T21:10:24Z","id":3285272,"body":"I've been trying to isolate this under GEvent but have been unsuccessful so far. eg:\r\n\r\n    import gevent, gevent.core, gevent.dns, socket, sys, urllib2\r\n    try:\r\n      print \"GEvent: \", gevent.core.get_method (), gevent.core.get_version ()\r\n    except Exception, e:\r\n      print e\r\n    try:\r\n      print \"gethostbyname: \", socket.gethostbyname ('google.com')\r\n    except Exception, e:\r\n      print e\r\n    try:\r\n      print \"GEvent resolve: \", gevent.dns.resolve_ipv4 ('google.com')\r\n    except Exception, e:\r\n      print e\r\n    try:\r\n      req = urllib2.Request (\r\n        \"http://sjclbirbl01.prod.yousendit.com:8090/rbl/YsiEncryption\",\r\n        headers = {\"Content-Type\" : \"application/soap+xml\"},\r\n        data = \"<xml />\")\r\n      rc = urllib2.urlopen (req)\r\n    except Exception, e:\r\n          print e\r\nWorks just fine and this fails:\r\n\r\n    python26 -c \"import gevent; from gevent import socket; from gevent.dns import resolve_ipv4; print socket.gethostbyname ('google.com'); print resolve_ipv4 ('google.com')\"\r\n\r\nand this works:\r\n\r\n    python26 -c \"import gevent, gevent.core, gevent.dns, gevent.socket, socket; print socket.gethostbyname ('google.com'); print gevent.dns.resolve_ipv4 ('google.com')\"\r\n\r\nDigging...\r\n\r\n\r\nIt only seems to fail under GUnicorn.  Trying to figure out why...","url":"https://api.github.com/repos/benoitc/gunicorn/issues/comments/3285272"},"action":"created"}