开发者

Unexpected error 500 when returning response in Django, what's going on?

I have a view in Django that returns error 500 and I can't figure out why. It looks something like that:

def some_view(request):
    result = some_func(request.raw_post_data)
    response = HttpResponse(status=200)
    response['Content-Type'] = 'application/json'
    response.content = simplejson.dumps(result)
    # if I log something here, it will be printed, so control reaches here
    return response

So it looks like my view is working correctly and something then happens in Django internals, but I'm unable to trace where exactly it happens. Any hint on what it is or how to find it?

Things that might be important:

  • I'm running Python 2.5 and Django 1.1.4
  • POST data contains a JSON array with around 1000 string entries, 50 bytes each
  • 开发者_如何学编程the response is around 100KiB
  • other views seem to work pefectly fine
  • DB operations are involved


The problem was that FastCGI module in Apache has 30s timeout and it took more than 30s for Django to prepare the response. Apache then returned the generic 500 error message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜