0

I am trying to use django-social-auth in my project. It's working good on my local computer (using manage.py runserver), but fails on my hoster's (locum.ru) server(using mod_wsgi).

I see this in my django logs on the server:

[2012-06-26 22:19:24,796] DEBUG  [django.db.backends:44] (0.000) SET FOREIGN_KEY_CHECKS=0;; args=()
[2012-06-26 22:19:24,817] DEBUG  [django.db.backends:44] (0.000) SELECT `django_session`.`session_key`, `django_session`.`session_dat
a`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`session_key` = 392a94a6d2a667ff755a9d45a79582d0  AN
D `django_session`.`expire_date` > 2012-06-26 22:19:24 ); args=('392a94a6d2a667ff755a9d45a79582d0', u'2012-06-26 22:19:24')
[2012-06-26 22:19:24,857] DEBUG  [myapp.context_processors:11] Adding something to context.

(myapp.context_processors is just a simple context processor that does nothing except notifying me that it's called)

and this in error.log:

[Tue Jun 26 22:19:24 2012] [error] [client 34.34.34.34] Premature end of script headers: django.wsgi

When I turn django-social-auth off in my settings.py everything works good. When I turn it on - it fails!

I have python 2.7.3 locally and python 2.6.6 on server (but it works without social-auth, so that it not the issue, I think...) and Django 1.3.1.

Can anyone give me a hint where to dig?

UPD: I added some logging and now I see that it fails on import from social_auth:

logger.debug('Before import from social_auth')
from social_auth.views import complete, auth, disconnect
logger.debug('After import from social_auth')

"Before import..." appears in debug log, "After ..." doesn't. But it works on my local desktop! Where is the magic?!

UPD2: I added some more logging into social_auth and now I see that social_auth imports python-openid, openid.yadis.extrd runs this lines:

from openid.oidutil import importElementTree
ElementTree = importElementTree()

and importElementTree() contains:

for mod_name in module_names:
    try:
        logger.debug('importElementTree - 2 - ' + mod_name)
        ElementTree = __import__(mod_name, None, None, ['unused'])
        logger.debug('importElementTree - 3 - ' + mod_name)
    except ImportError:
        logger.debug('importElementTree - except ImportError')
        pass

in log file appears:

[2012-06-30 09:18:51,186] DEBUG  [shoplist:39] In openid.yadis.extrd - 5
[2012-06-30 09:18:51,186] DEBUG  [shoplist:56] importElementTree
[2012-06-30 09:18:51,186] DEBUG  [shoplist:61] importElementTree - 1
[2012-06-30 09:18:51,186] DEBUG  [shoplist:64] importElementTree - 2 - lxml.etree

So, it fails to import lxml.etree, but doesn't throw ImportError. Why? I checked that i have the same versions of django-social-auth, python-openid and python-lxml on local computer and on the server. And it still does'n work on the server!

kotslon
  • 147
  • 10

1 Answers1

0

Indicates you are likely using daemon mode bit the process is crashing. If you cant see main Apache error log though and only virtual host, you may not be able to see crash message.

See if you can force application to run in main interpreter within the process rather than a sub interpreter.

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • WSGIApplicationGroup %{GLOBAL} must be used in apache .conf file? But I can't reach apache configuration on virtual hosting :( – kotslon Jun 27 '12 at 15:53
  • If the sub interpreter usage is the issue then there will be nothing you can do, unless you can get your hosting service to change the configuration for you. What configuration are you placing in .htaccess file now, or does hosting service even prohibit that and only allow you to put .wsgi or .py files in specified directories? – Graham Dumpleton Jun 28 '12 at 03:54
  • "only allow you to put .wsgi or .py files in specified directories" - exactly. I can edit my wsgi and .py files only. – kotslon Jun 28 '12 at 08:04