Not specific Rhino related maybe, but I run into an issue where a folder and/or file remain locked after running a series of python scripts.
I’m using the Logging module to write a logfile during the runtime of the script.
However if I run the script again, I cannot delete the folder the logfile is in.
Even in Windows explorer I’m not allowed to delete the log file.
What is strange is that it appears that ‘after some time’ I am able to delete the file, as if Windows is holding it locked for some time before releasing it.
Can someone point me in the right direction how to tackle this? it’s unfamiliar terrain for me. How would I find the cause and proper solution to force windows to release/delete a folder?
EDIT: I found a solution by closing the logfile viw it’s handler like so at the end of the script:
for handler in logging.getLogger().handlers: # https://docs.python.org/2/library/logging.handlers.html#filehandler if isinstance(handler,logging.FileHandler): handler.close()