zoukankan      html  css  js  c++  java
  • Django开发模式会加载两次settings文件导致RotatingFileHandlerError

    当使用RotatingFileHandler作为django的日志处理器的时候,会报:

    Traceback (most recent call last):
    File "C:Python27liblogginghandlers.py", line 78, in emit
    self.doRollover()
    File "C:Python27liblogginghandlers.py", line 141, in doRollover
    os.rename(self.baseFilename, dfn)
    WindowsError: [Error 32] The process cannot access the file because it is being used by another process

    原因是:在开发模式下,通过python manage.py runserver的方式启动django的时候,会启动两个线程去加载settings文件,一个是用来给你服务的,另一个是监控settings文件是否改变的,如果改变就立即让他生效,所以会导致上面的错误,解决方法是加上--noreload参数。

    python manage.py runserver --noreload

    参见老外的日志:

    http://azaleasays.com/2014/05/01/django-logging-with-rotatingfilehandler-error/

  • 相关阅读:
    爬虫示例
    S20_DAY23--课堂笔记
    python--常用模块之正则
    S20_DAY22--课堂笔记
    win10系统重装
    CCF 命令行选项
    CCF 任务调度
    CCF 出现次数最多的数
    CCF ISBN
    CCF 最大的矩形
  • 原文地址:https://www.cnblogs.com/413xiaol/p/6854312.html
Copyright © 2011-2022 走看看