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
8 changes: 6 additions & 2 deletions wish/python/src/wish_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ NB_MODULE(wish_ext, m) {
.def(nb::init<const std::string&, const std::string&,
const std::string&, const std::string&, int>())
.def("init", [](TlsClientPy& self) {
return self.client.Init();
if (!self.client.Init()) {
throw std::runtime_error("TlsClient.init() failed");
}
})
.def("set_on_open", [](TlsClientPy& self, nb::object cb) {
self.on_open_cb = cb;
Expand Down Expand Up @@ -291,7 +293,9 @@ NB_MODULE(wish_ext, m) {
nb::class_<PlainClientPy>(m, "PlainClient", nb::type_slots(plain_slots))
.def(nb::init<const std::string&, int>())
.def("init", [](PlainClientPy& self) {
return self.client.Init();
if (!self.client.Init()) {
throw std::runtime_error("PlainClient.init() failed");
}
})
.def("set_on_open", [](PlainClientPy& self, nb::object cb) {
self.on_open_cb = cb;
Expand Down
3 changes: 1 addition & 2 deletions wish/python/wish/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def __init__(self, host, port, tls, ca_file="", cert_file="", key_file=""):
self._client = wish_ext.TlsClient(ca_file, cert_file, key_file, host, port)
else:
self._client = wish_ext.PlainClient(host, port)
if not self._client.init():
raise RuntimeError(f"Failed to initialize client for {host}:{port}")
self._client.init() # raises RuntimeError on failure

self._loop = asyncio.get_running_loop()
self._recv_queue = asyncio.Queue()
Expand Down