fix 日志首次读取部分数据

This commit is contained in:
jxxghp 2023-08-15 07:12:43 +08:00
parent e76606823f
commit 5da3406647

View File

@ -112,8 +112,8 @@ def get_logging(token: str):
def log_generator(): def log_generator():
log_path = settings.LOG_PATH / 'moviepilot.log' log_path = settings.LOG_PATH / 'moviepilot.log'
texts = tailer.tail(open(log_path, 'r'), 50) texts = tailer.tail(open(log_path, 'r'), 50)
yield 'data: %s\n\n' % '\n'.join(texts)
while True: while True:
yield 'data: %s\n\n' % '\n'.join(texts)
for text in tailer.follow(open(log_path, 'r')): for text in tailer.follow(open(log_path, 'r')):
yield 'data: %s\n\n' % (text or '') yield 'data: %s\n\n' % (text or '')
time.sleep(1) time.sleep(1)