restore use_default_signal_handler flag for libmambapy (#3028)

This commit is contained in:
Daniel Holth 2023-12-07 17:33:23 -05:00 committed by GitHub
parent 21675b6517
commit d12d77056c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -63,6 +63,8 @@ namespace mamba
{ {
public: public:
static void use_default_signal_handler(bool val);
struct RemoteFetchParams struct RemoteFetchParams
{ {
// ssl_verify can be either an empty string (regular SSL verification), // ssl_verify can be either an empty string (regular SSL verification),

View File

@ -68,9 +68,22 @@ namespace mamba
return static_cast<spdlog::level::level_enum>(l); return static_cast<spdlog::level::level_enum>(l);
} }
namespace
{
std::atomic<bool> use_default_signal_handler_val{ true };
}
void Context::use_default_signal_handler(bool val)
{
use_default_signal_handler_val = val;
}
void Context::enable_logging_and_signal_handling(Context& context) void Context::enable_logging_and_signal_handling(Context& context)
{ {
set_default_signal_handler(); if (use_default_signal_handler_val)
{
set_default_signal_handler();
}
context.logger = std::make_shared<Logger>("libmamba", context.output_params.log_pattern, "\n"); context.logger = std::make_shared<Logger>("libmamba", context.output_params.log_pattern, "\n");
MainExecutor::instance().on_close( MainExecutor::instance().on_close(

View File

@ -731,6 +731,7 @@ bind_submodule_impl(pybind11::module_ m)
); );
} }
)) ))
.def_static("use_default_signal_handler", &Context::use_default_signal_handler)
.def_readwrite("offline", &Context::offline) .def_readwrite("offline", &Context::offline)
.def_readwrite("local_repodata_ttl", &Context::local_repodata_ttl) .def_readwrite("local_repodata_ttl", &Context::local_repodata_ttl)
.def_readwrite("use_index_cache", &Context::use_index_cache) .def_readwrite("use_index_cache", &Context::use_index_cache)