Impossible to run gunicorn with django-split-settings
benjaminrigaud opened this issue · 2 comments
benjaminrigaud commented
Running the command :
python manage.py run_gunicorn
Produces the following stack trace:
2013-08-21 13:28:17 [8477] [INFO] Starting gunicorn 0.17.4
Starting gunicorn 0.17.4
2013-08-21 13:28:17 [8477] [INFO] Listening at: http://0.0.0.0:7777 (8477)
Listening at: http://0.0.0.0:7777 (8477)
2013-08-21 13:28:17 [8477] [INFO] Using worker: sync
Using worker: sync
2013-08-21 13:28:17 [8486] [INFO] Booting worker with pid: 8486
Booting worker with pid: 8486
2013-08-21 13:28:17 [8486] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in spawn_worker
worker.init_process()
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 106, in wsgi
self.callable = self.load()
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 134, in load
return mod.make_command_wsgi_application(self.admin_media_path)
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
reload_django_settings()
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 54, in reload_django_settings
reload(mod)
File "/home/myhome/projects/myvirtualenv/myproject/settings/production.py", line 31, in <module>
scope=locals()
File "/home/myhome/.virtualenvs/myvirtualenv/local/lib/python2.7/site-packages/split_settings/tools.py", line 40, in include
confpath = os.path.dirname(including_file)
File "/home/myhome/.virtualenvs/myvirtualenv/lib/python2.7/posixpath.py", line 120, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
locals()['included_file'] exists but is set to None
A quick fix could be to replace the line (in tools.py):
including_file = scope.get('__included_file__', scope['__file__'])
by
including_file = scope.get('__included_file__') or scope['__file__']
akaihola commented
Thanks for the report! Could you try if the above patch fixes this? It's a change I had to make previously in one particular project to make split settings work correctly, and I didn't commit it into this repository since we didn't hit the same issue elsewhere.
benjaminrigaud commented
Amazing response time :)
Yep, the patch fixes it. Thanks!