I have written a small program trivially converting quite a bit of data into an Excel sheet on Windows using xlsxwriter which I then manually open in Excel for further analysis.
If I already have the file open in Excel and forget to explicitly close it, xlsxwriter fails when it tries to save the in-memory sheet to disk with a Permission denied. I understand that this is how Windows behaves, as opposed to Linux.
I would like to detect that the file is already open in Excel in the beginning of my program so I can fail fast, instead after a while.
How do I detect this in Python 3.8.5?