jneight / django-db-geventpool

Another DB pool using gevent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patching gevent on Django 1.7.1 causes ImproperlyConfigured error

brockhaywood opened this issue · comments

Not really sure where this issue belongs but it's very similar in result to: benoitc/gunicorn#527

I find that when I invoke psycogreen.gevent.patch_psycopg() it results in the following errors from Django:

ImproperlyConfigured: The included urlconf 'urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

It only appears to occur for the first request on the worker. Subsequent requests appear to be ok.

If I don't do the patch_psycopg, the errors go away.

I'm using Django 1.7.1, Gunicorn 18.0, gevent 1.0.1 and psycogreen 1.0. I'm also using Tastypie for APIs.

Any thoughts on this?

Hello,

Have you seen this workaround from @salty-horse?, or maybe try updating django and gunicorn versions, all the info I have found are always talking about being a bug in django.

def post_fork(server, worker):
    from django.core.urlresolvers import resolve
    resolve('some valid url')

Yes, I have tried that workaround with no success. It results in:

"django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time."

The latest gunicorn has a blocker with Django 1.7.1 (benoitc/gunicorn#927) but I will try updating Django.

Upgrading Django unfortunately does not resolve this issue.

Can you try the branch fix/927 and let me know if it solves your issue?

Also which command are you running?

@benoitc I'm sorry, I don't follow "which command are you running", are you asking how I'm running gunicorn? If so:

gunicorn -w 1 --max-requests=1000 -b 0.0.0.0:8000 -k gevent --config ogs/gunicorn.py --pythonpath ogs wsgi:application

@brockhaywood sorry I meant "command line" :) Just wanted to know if you were using the gunicorn command without preload. Which is the case.

Anyway can you try the branch fix/927 and let me know if it solves your issue?

Ok great, testing now

Yes, that does fix the issue for me

However, when running with worker count of 3, the issue remains.

@brockhaywood did you pass the django settings in the env?

Yes, $DJANGO_SETTINGS_MODULE is set in the environment

hrm could you rather try the following command line:

gunicorn --env DJANGO_SETTINGS_MODULE=testing.settings -k gevent -w3 wsgi:application

of course you will need to change the name of the project

Appears to be resolvable within gunicorn as referenced here benoitc/gunicorn#927 so closing this