Open gdementen opened 2 years ago
see #638
xlwings now does something like this (kill zombie instances) by default from 0.30.2 See https://github.com/xlwings/xlwings/pull/2191 and https://docs.xlwings.org/en/latest/whatsnew.html#v0-30-2-mar-16-2023
However, as of today (2024-02-26), there is still no package in anaconda for 0.30.x yet (there are in conda-forge though).
Ref: https://anaconda.org/anaconda/xlwings and https://anaconda.org/conda-forge/xlwings/files
Whenever one kills (not stops) a model which opened an Excel file (even if the file is closed when the model is killed), this leaves an empty Excel instance around (because the atexit "kill_global_app" is never called).
This problem is made a lot worse when using run_editor_on_exception() because of our too broad except hook (see larray-project/larray-editor#231) which means we effectively kill programs a lot more often.
I see two options to avoid the proliferation of such empty Excel instances (besides fixing larray-project/larray-editor#231). Either we kill all empty Excel instances before we create a new one, or we reuse an existing one.
I think reusing is slightly better because it is better for performance (avoids opening an Excel instance) and should be enough to avoid proliferation given than we only ever leave behind one extra empty Excel instance at a time. That leaves us with three questions:
I can imagine edge cases where this behavior would interact badly with another program trying to pilot Excel at the same time, but this would be so rare that enabling this option by default seems the better choice but I think I would rather do it unconditionally and wait until somebody has a an actual problem with it to implement the argument to disable it.
@alixdamman Do you agree with my analysis?