import requests, json, logging, datetime from logging.handlers import RotatingFileHandler from flask import current_app, render_template logger_dealer = logging.getLogger('dealer') formatter = logging.Formatter( '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]') file_handler_dealer = RotatingFileHandler('logs/dealer.log', maxBytes=10240, backupCount=10) file_handler_dealer.setFormatter(formatter) file_handler_dealer.setLevel(logging.DEBUG) logger_dealer.setLevel(logging.DEBUG) logger_dealer.addHandler(file_handler_dealer)
набирается файл до 10Кб и далее и интерпретатор пишет в трайсбэк:
— Logging error —
Traceback (most recent call last):
File “/usr/local/lib/python3.6/logging/handlers.py”, line 72, in emit
self.doRollover()
File “/usr/local/lib/python3.6/logging/handlers.py”, line 173, in doRollover
self.rotate(self.baseFilename, dfn)
File “/usr/local/lib/python3.6/logging/handlers.py”, line 113, in rotate
os.rename(source, dest)
OSError: Text file busy: ‘/project/logs/dealer.log’ -> ‘/project_shop/logs/dealer.log.1’
Подскажите, как быть с этим?
Спасибо.