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: 10 additions & 0 deletions src/xcomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ namespace xpyt
.def(py::init<>())
.def("register_target", &xcomm_manager::register_target);

comm_module.def("create_comm", [&comm_module](py::args objs, py::kwargs kw) {
return comm_module.attr("Comm")(*objs, **kw);
});

comm_module.def("get_comm_manager", [&comm_module]() {
static py::object comm_manager = comm_module.attr("CommManager")();

return comm_manager;
});

return comm_module;
}

Expand Down
4 changes: 3 additions & 1 deletion src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ namespace xpyt
py::module comm_module = get_comm_module();
py::module kernel_module = get_kernel_module();

// Monkey patching "from ipykernel.comm import Comm"
// Old approach: ipykernel provides the comm
sys.attr("modules")["ipykernel.comm"] = comm_module;
// New approach: we provide our comm module
sys.attr("modules")["comm"] = comm_module;

instanciate_ipython_shell();

Expand Down