一些技术规格:
- CentOS 6.0
- uWSGI 0.9.9.2
- Nginx 1.0.5
- Django 1.3.1
uWSGI:
[uwsgi]
socket = 127.0.0.1:3031
master = true
processes = 5
uid = xx
gid = xx
env = DJANGO_SETTINGS_MODULE=xx.settings
module = django.core.handlers.wsgi:WSGIHandler()
post-buffering = 8192
harakiri = 30
harakiri-verbose = true
disable-logging = true
logto = /var/log/xx.log
vacuum = true
optimize = 2
JSON序列izer:
class LazyEncoder(simplejson.JSONEncoder, json.Serializer):
def default(self, obj):
if isinstance(obj, Promise):
return force_unicode(obj)
if isinstance(obj, Decimal):
u_value = force_unicode(obj)
if u . in u_value:
return float(u_value)
return int(u_value)
return super(lazy_encoder, self).default(obj)
纽约总部 HttpResponse:
class JsonResponse(HttpResponse):
status_code = 200
json_status_code = 200
message = _( OK )
def __init__(self, json={}, *args, **kwargs):
mimetype = kwargs.pop( mimetype , application/json )
if not status in json:
json[ status ] = { code : self.json_status_code, message : self.message}
super(JsonResponse, self).__init__(LazyEncoder(indent=settings.DEBUG and 4 or None, separators=settings.DEBUG and ( , , : ) or ( , , : )).encode(json), mimetype=mimetype, *args, **kwargs)
我有几句JsonResponse与其他一些json_status_code和电文。
观点:
....
if application.status == Application.STATUS_REMOVED:
return JsonApplicationSuspendedResponse()
....
return JsonResponse()
<><>>>>
即使在申请状况发生变化时,我还是收到3至4秒的老小 j,然后回到JsonApplication SuspbilResponse正确。
I checked the database application status update takes place immediately, also noticed that if I reboot uWSGI and send request response is correct and the opposite situation happens. Second request after status change can have old json.
It looks as if they write the response for few sencods and had a problem with her refresh (Cache is disabled).
Any ideas where it might be the problem ?
同一法典在Appa2和Mod_wsgi实施罚款。
<>限值>
在JsonResponse,我说:
def __init__(self, json={}, *args, **kwargs):
<<>json={>>>>部分非常重要,JsonResponse和JsonResponse在共享初始字典及其内容后各分流,因此答案不改变。
def __init__(self, json=None, *args, **kwargs):
mimetype = kwargs.pop( mimetype , application/json )
if not json:
json = {}
if not status in json:
json[ status ] = { code : self.json_status_code, message : self.message}
Thanks for your time