python does not release filehandles to logfile

后端 未结 3 409
误落风尘
误落风尘 2020-11-28 10:02

I have an application which has to run a number of simulation runs. I want to setup a logging mechanisme where all logrecords are logged in a general.log, and all logs for a

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 10:17

    You need to call .close() on the filehandler.

    When your Run class completes, call:

    handlers = self.log.handlers[:]
    for handler in handlers:
        handler.close()
        self.log.removeHandler(handler)
    

提交回复
热议问题