V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
dhq
V2EX  ›  Django

django、nginx 运行报错,页面显示 Unhandle Exception, django debug = true 重启可解决,难得一见,求助!

  •  
  •   dhq · 2018-05-08 18:29:20 +08:00 · 2955 次点击
    这是一个创建于 2376 天前的主题,其中的信息可能已经有所发展或是发生改变。

    标签

    • django
    • nginx
    • fastcgi

    错误描述

    • 一个 django 应用,通过 nginx 部署被访问,一直没事,运行一段时间后
    • 界面频繁刷新界面偶尔会显示 unhandle exception
    • 重启 django 马上恢复
    • 小弟毫无头绪,望大佬赐教,以身相许

    nginx 报错信息

    ImportError: cannot import name debug" while reading response header from upstream
    

    django DEBUG

    DEBUG = True

    django 运行方式

    /usr/bin/python /opt/xxx/xxx/manage.py runfcgi method=prefork host=127.0.0.1 port=7001
    ...
    ...
    /usr/bin/python /opt/xxx/xxx/manage.py runfcgi method=prefork host=127.0.0.1 port=7001
    

    nginx 配置

    server
    {
            listen  80;
            server_name  dhq.dhq.lab;
            proxy_connect_timeout   3000000;
            proxy_send_timeout      3000000;
            proxy_read_timeout      3000000;
            client_max_body_size    50g;
    
            location / {
                    fastcgi_pass 127.0.0.1:7001;
                    fastcgi_pass_header Authorization;
                    fastcgi_intercept_errors off;
                    fastcgi_param PATH_INFO $fastcgi_script_name;
                    fastcgi_param REQUEST_METHOD $request_method;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param CONTENT_TYPE $content_type;
                    fastcgi_param CONTENT_LENGTH $content_length;
                    fastcgi_param SERVER_PORT $server_port;
                    fastcgi_param SERVER_PROTOCOL $server_protocol;
                    fastcgi_param SERVER_NAME $server_name;
                    fastcgi_param REQUEST_URI $request_uri;
                    fastcgi_param DOCUMENT_URI $document_uri;
                    fastcgi_param DOCUMENT_ROOT $document_root;
                    fastcgi_param SERVER_ADDR $server_addr;
                    fastcgi_param REMOTE_USER $remote_user;
                    fastcgi_param REMOTE_ADDR $remote_addr;
                    fastcgi_param REMOTE_PORT $remote_port;
                    fastcgi_param SERVER_SOFTWARE "nginx";
                    fastcgi_param GATEWAY_INTERFACE "CGI/1.1";
                    fastcgi_connect_timeout 5000;
                    fastcgi_read_timeout 5000;
                    fastcgi_send_timeout 5000;
            }
            location /static {
                alias /opt/xxx/xxx/media;
                access_log off;
            }
            location /media {
                alias /opt/xxx/xxx/media;
                access_log off;
            }
            access_log  /var/log/nginx/xxx.log  web;
    }
    
    

    nginx error log

    http://192.168.0.24/nasmp/v4.1/xxxx"
    2018/05/08 11:25:32 [error] 2579#0: *9120 FastCGI sent in stderr: "Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/flup/server/fcgi_base.py", line 558, in run
      File "/usr/lib/python2.7/site-packages/flup/server/fcgi_base.py", line 1118, in handler
      File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
      File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response
      File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 202, in handle_uncaught_exception
    ImportError: cannot import name debug" while reading response header from upstream, client: 192.168.0.189, server: dhq.dhq.com, request: "GET /nasmp/v4.1/downloadstaticfile_nasmpv4?filepath=nasclient/chrome_installer.exe HTTP/1.1", upstream: "fastcgi://127.0.0.1:7001", host: "192.168.0.24", referrer: "
    
    5 条回复    2018-05-09 09:36:24 +08:00
    dhq
        1
    dhq  
    OP
       2018-05-08 18:52:05 +08:00 via iPhone
    Django 1.3.7
    Python 2.7
    kumakiti
        2
    kumakiti  
       2018-05-08 19:01:39 +08:00 via iPhone
    找你自己写的代码的部分,说的很明显了
    dhq
        3
    dhq  
    OP
       2018-05-08 19:39:33 +08:00 via iPhone
    @kumakiti 你是说下载浏览器那个请求吗,每个请求都是这样的报错,只是说在不同的页面里显示这个 unhandleunhandle excptexception,哥你是有遇见过吗
    Hopetree
        4
    Hopetree  
       2018-05-09 09:08:03 +08:00
    哇,好古老的 python 和 django
    dhq
        5
    dhq  
    OP
       2018-05-09 09:36:24 +08:00
    @Hopetree 对啊,有遇到过类似的吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2984 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:57 · PVG 18:57 · LAX 02:57 · JFK 05:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.