码迷,mamicode.com
首页 > 其他好文 > 详细

Django开发模式会加载两次settings文件导致RotatingFileHandlerError

时间:2017-05-14 23:44:59      阅读:528      评论:0      收藏:0      [点我收藏+]

标签:线程   tin   rename   nbsp   handler   trace   com   with   run   

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

Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 78, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.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/

Django开发模式会加载两次settings文件导致RotatingFileHandlerError

标签:线程   tin   rename   nbsp   handler   trace   com   with   run   

原文地址:http://www.cnblogs.com/413xiaol/p/6854312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!