سؤال

I'm running the below code slightly modfied from gunicorn's website (http://gunicorn.org/run.html)

import urllib2

def app(environ, start_response):
    print "in app"
#    response=urllib2.urlopen('http://www.google.com')
    data = 'Hello, World!\n'
    response_headers = [
        ('Content-type','text/plain'),
        ('Content-Length', str(len(data)))
    ]
    start_response('200 OK', response_headers)
    print "    starting response"
    return iter([data])

It runs completely as expected except when I uncomment the urrllib2.urlopen line, the entire code fails silently.

I'm running gunicorn with no conf file specified, meaning errors should be written to stdout (there aren't any). The browser making the request to gunicorn errors and claims "No date received"

Any idea what's going? I haven't found anything even remotely related to this elsewhere on the web.

Thanks!

هل كانت مفيدة؟

المحلول

I figured this one out by looking here: https://github.com/benoitc/gunicorn/issues/38

which pointed me to this documented bug in urllib2 on OS X - https://trac.macports.org/ticket/24421

I managed to fix it by using python 2.6.6 instead of python 2.6.5 - pretty sure I installed them differently as well which could have also been the fix. Another of the suggested fixes was to downgrade python to 2.6.4

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top