safety close log file
This commit is contained in:
parent
9fcaa5df25
commit
95c7ee717b
10
sample.py
10
sample.py
@ -41,8 +41,14 @@ def handle_sighup(signum, frame):
|
||||
global room_status_log
|
||||
|
||||
for room_id in log_files:
|
||||
log_files[room_id].close()
|
||||
room_status_log.close()
|
||||
try:
|
||||
log_files[room_id].close()
|
||||
except Exception as e:
|
||||
logger.exception(f"close log_files[{room_id}] failed with {e}")
|
||||
try:
|
||||
room_status_log.close()
|
||||
except Exception as e:
|
||||
logger.exception(f"close room_status_log failed with {e}")
|
||||
|
||||
log_files = {}
|
||||
room_status_log = open("logs/room_status.jsonl", "a", encoding="utf-8")
|
||||
|
Loading…
Reference in New Issue
Block a user