-
Notifications
You must be signed in to change notification settings - Fork 252
Description
The kilosort4.log FileHandler is never closed after run_sorter(), causing PermissionError on Windows: When using si.sorters.run_sorter("kilosort4", ...) on Windows, my local sorter output folder cannot be deleted afterwards because kilosort4.log is still locked by the Python process.
Kilosort4's setup_logger() in kilosort/run_kilosort.py (line ~451) adds a logging.FileHandler to the 'kilosort' logger. Kilosort provides a close_logger() function to clean this up, but SpikeInterface never calls it after sorting completes. Specifically in spikeinterface/sorters/external/kilosort4.py, the _run_from_folder() method calls kilosort functions that trigger setup_logger(), but after sorting finishes there is no call to close_logger(). The FileHandler stays attached to the 'kilosort' logger indefinitely, keeping kilosort4.log open for the lifetime of the Python process. Because of this, any shutil.rmtree() or file deletion on the sorter output folder fails with PermissionError: [WinError 32]. This breaks my automated pipeline that copy results to a network drive and cleans up local temp folders.
Thanks!