Skip to content

Commit

Permalink
added kernel alive variable
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Jun 17, 2024
1 parent 05ddd63 commit 0daf473
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/test_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,10 @@ void debugger_client::start()
void debugger_client::shutdown()
{
m_client.stop_channels();
if (!m_client.kernel_alive)
{
throw std::runtime_error("Kernel is not alive. Cannot send shutdown request.");
}
m_client.send_on_control("shutdown_request", make_shutdown_request());
m_client.receive_on_control();
}
Expand Down
14 changes: 13 additions & 1 deletion test/xeus_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,26 @@ xeus_logger_client::xeus_logger_client(xeus::xcontext& context,
std::ofstream out(m_file_name);
out << "STARTING CLIENT" << std::endl;

// TODO
p_client->connect();
register_kernel_status_listener();
}

xeus_logger_client::~xeus_logger_client()
{
}

void xeus_logger_client::register_kernel_status_listener()
{
p_client->register_kernel_status_listener([this](bool status) {
handle_kernel_status_message(status);
});
}

void xeus_logger_client::handle_kernel_status_message(bool status)
{
kernel_alive = status;
}

void xeus_logger_client::send_on_shell(const std::string& msg_type, nl::json content)
{
nl::json header = xeus::make_header(msg_type, m_user_name, xeus::new_xguid());
Expand Down
5 changes: 5 additions & 0 deletions test/xeus_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ class xeus_logger_client
void stop_channels();
void log_message(nl::json msg);

void register_kernel_status_listener();
bool kernel_alive = false;

private:

void handle_kernel_status_message(bool status);

std::string m_user_name;
std::string m_file_name;
std::mutex m_file_mutex;
Expand Down

0 comments on commit 0daf473

Please sign in to comment.