File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,7 +84,15 @@ namespace xpyt
8484
8585 const xeus::xtarget* xcomm::target (const py::object& target_name) const
8686 {
87- return xeus::get_interpreter ().comm_manager ().target (target_name.cast <std::string>());
87+ auto & comm_manager = xeus::get_interpreter ().comm_manager ();
88+ auto res = comm_manager.target (target_name.cast <std::string>());
89+ if (!res)
90+ {
91+ comm_manager.register_comm_target (
92+ target_name.cast <std::string>(), [](xeus::xcomm&&, const xeus::xmessage&) {}
93+ );
94+ }
95+ return comm_manager.target (target_name.cast <std::string>());
8896 }
8997
9098 xeus::xguid xcomm::id (const py::kwargs& kwargs) const
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ namespace xpyt
4040
4141 private:
4242
43+ // Warning: this function creates and register the target with a dummy
44+ // comm_open handler when the target does not exist, so that create_comm
45+ // has the same behavior as ipykernel.
4346 const xeus::xtarget* target (const py::object& target_name) const ;
4447 xeus::xguid id (const py::kwargs& kwargs) const ;
4548 cpp_callback_type cpp_callback (const python_callback_type& callback) const ;
You can’t perform that action at this time.
0 commit comments