Re: Multiprocess and Global State

23 views
Skip to first unread message

Roberto De Ioris

unread,
May 23, 2013, 1:00:54 PM5/23/13
to django...@googlegroups.com

> I all,
>
> Environment:
> - Django 1.5.1
> - mongoengine 0.8.1
>
> I use mongoengine to store and manage user accounts authentication.
>
> it work fine with the development server and uwsgi : only if I use a
> single
> process or thread mode.
>
> If i use more than 1 process, sometime ( when i refresh my application ),
> i
> am redirected on my login form.
>
> All my request must be authentified, i use a middleware to do this :
>
> from django.http import HttpResponse,HttpResponseRedirect
>> class AuthenticationMiddleware(object):
>>
>> _LOGIN_PATH = "/accounts/login_view/"
>>
>> def process_request(self, request):
>> if (request.path != self._LOGIN_PATH) and not request.is_ajax():
>> if not request.user.is_authenticated():
>> return HttpResponseRedirect( self._LOGIN_PATH+'?next=%s'
>> %
>> request.path)
>> return None
>
>
> I think , there are unshared data between the processes who causes this
> problem.
>
> What do you think?
>
>
> Note : it works well with gunicorn
>
> Ch.
>


If it works well with gunicorn it could be a problem with how (or better
'when') you open the connection to mongodb.

Add --lazy-apps to uWSGI options to load the application after fork()
(like gunicorn)


--
Roberto De Ioris
http://unbit.it
Reply all
Reply to author
Forward
0 new messages