Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

gunicorn doesn't return any response when urllib2 is used #38

Closed
nautilebleu opened this Issue · 6 comments

3 participants

Goulwen Reboux Paul J. Davis Benoit Chesneau
Goulwen Reboux

The following code reproduces the issue. No matter the arbiter or the timeout or the keepalive values, gunicorn crashes. Event the try: except: does not prevent gunicorn to crash.

:::Python
# -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license. 
# See the NOTICE for more information.
#
# Example code from Eventlet sources

from wsgiref.validate import validator
import urllib2
import eventlet
#
#eventlet.monkey_patch(all=True)

#@validator
def app(environ, start_response):
    """Simplest possible application object"""
    data = ''
    try:
        f = urllib2.urlopen('http://google.fr/')
    except:
        data += 'Unable to open an url with urllib'
    data += 'Hello, WorldWideWeb!\n'
    status = '200 OK'
    response_headers = [
        ('Content-type','text/plain'),
        ('Content-Length', str(len(data)))
    ]
    start_response(status, response_headers)
    return iter([data])
Paul J. Davis
Collaborator

When does gunicorn crash? When you first request the URL? Or earlier?

You reported earlier that there's no crash if you comment out the urllib call as well right?

Could you also try something like this:

def app(environ, start_response):
    """Simplest possible application object"""
    data = ''
    try:
        f = urllib2.urlopen('http://google.fr/')
        data += 'Hello, WorldWideWeb!\n'
        status = '200 OK'
        response_headers = [
            ('Content-type','text/plain'),
            ('Content-Length', str(len(data)))
        ]
        start_response(status, response_headers)
        return iter([data])
    except:
        print "CAUGHT EXCEPTION"

I'm unable to get this to trigger locally. I tried at home last night on 10.6 as well, but specific versions for this Ubuntu machine are:

Ubuntu 9.04
Python 2.6.2
Gunicorn 0.7.2 (checked out from tag)
eventlet 0.9.7
libev 3.0.0

This is such a weird bug...

Goulwen Reboux

The server starts correctly but I'm unable to get a response the browser. In fact, gunicorn doesn't crash: the server is accessed but no response is returned. For one request with your code from the browser, gunicorn display 3 rows:

~ gunicorn -a "egg:gunicorn#eventlet" --debug --bind localhost:8088 delicious:app
2010-04-20 23:10:27 [81032] [INFO] Worker spawned (pid: 81032)
2010-04-20 23:10:27 [81033] [INFO] Worker spawned (pid: 81033)
2010-04-20 23:10:28 [81034] [INFO] Worker spawned (pid: 81034)

My configuration

MacOS 10.6.3
virtualenv 1.4.5
Python 2.6.5 installed via MacPort
gunicorn 0.7.2 installed via pip or via git master
eventlet 0.9.7
greenlet 0.3.1

Weird as my conf doen't seem to different from yours.

Benoit Chesneau
Owner

i can't reproduce either . Also there is something weird in your install. If you run debug it should only use one worker. Do you have some configuration file somewhere ?

Paul J. Davis
Collaborator

Yeah, remember that settings from gunicorn.conf.py will be picked up by default. Though I'm not seeing how that would explain this.

One more thing to try, in the app module can you add these lines to the top:

import eventlet.debug
deventlet.debug.hub_exceptions(True)
Paul J. Davis
Collaborator

Ben Bangert reported this exact problem on IRC tonight. After some digging he turned up a similar report for Mac Ports' build of 2.6.5 with urllib2 and NOT gunicorn at [1].

Still trying to pin this down.

[1] https://trac.macports.org/ticket/24421

Goulwen Reboux

OK So I hope the next release of MacPort Python will correct this problem.

I close the issue as it's finally not related to gunicorn.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.