Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/xcomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ namespace xpyt

const xeus::xtarget* xcomm::target(const py::object& target_name) const
{
return xeus::get_interpreter().comm_manager().target(target_name.cast<std::string>());
auto& comm_manager = xeus::get_interpreter().comm_manager();
auto res = comm_manager.target(target_name.cast<std::string>());
if (!res)
{
comm_manager.register_comm_target(
target_name.cast<std::string>(), [](xeus::xcomm&&, const xeus::xmessage&) {}
);
}
return comm_manager.target(target_name.cast<std::string>());
}

xeus::xguid xcomm::id(const py::kwargs& kwargs) const
Expand Down
3 changes: 3 additions & 0 deletions src/xcomm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace xpyt

private:

// Warning: this function creates and register the target with a dummy
// comm_open handler when the target does not exist, so that create_comm
// has the same behavior as ipykernel.
const xeus::xtarget* target(const py::object& target_name) const;
xeus::xguid id(const py::kwargs& kwargs) const;
cpp_callback_type cpp_callback(const python_callback_type& callback) const;
Expand Down
Loading