Skip to content

kilosort4.log not being closed #4470

@fasfsd1564ew

Description

@fasfsd1564ew

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions