mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.57k stars 343 forks source link

Hotfix to allow Ctrl+C in python scipts #3285

Closed Klaim closed 2 months ago

Klaim commented 2 months ago

Partial fix for #3271 , in particular this makes the script in that issue work.

While there are major issues with the signal handling implementation in libmamba (and the fact that ideally it should be a cancelling system with async high-level functions being cancellable, and then scripts/executables decide how to trigger that cancelling), this only helps if Context.use_default_signal_handler(False) (or the equivalent in C++) is used. That function had no effect before this PR because the boolean it sets was only taken into account at the construction of the Context instance, which necessarilly must happen before the function can be called. To make it effective I (with the help of @Hind-M ) just made sure that the meaning of the variable is re-applied when the function is set. This might break some usage once called, not sure. We discussed with @Hind-M and @JohanMabille a future long-term solution for this but it will not come soon so this is the quickest hotfix for now.