make sure logger file is closed
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
+import atexit
import functools
import logging
import os
@@ -98,7 +99,9 @@ def setup_logger(
# with the same file name can safely write to the same file.
@functools.lru_cache(maxsize=None)
def _cached_log_stream(filename):
- return PathManager.open(filename, "a")
+ io = PathManager.open(filename, "a")
+ atexit.register(io.close)
+ return io
"""
