capnproto / pycapnp

Cap'n Proto serialization/RPC system - Python bindings
BSD 2-Clause "Simplified" License
458 stars 125 forks source link

Unable to raise KjException of type DISCONNECTED inside a server #324

Open tobiasah opened 10 months ago

tobiasah commented 10 months ago

Is there a way to cause the pycapnp server implementation to send a KjException with Type kj::Exception::Type::DISCONNECTED to the client?

Background We have a streaming mechanism based on the stream functionality. The Client is implemented in c++ and expects a kj::Exception of type kj::Exception::Type::DISCONNECTED for a proper disconnect.

As an additional note the server is no longer needed after that disconnect. Also, the only reference to this server is held by pycapnp itself.

I tried doing that in the python client by:

raise capnp.KjException(
    type=capnp.KjException.Type.DISCONNECTED, message=msg
)

The C++ client does receive the exception but it is of type kj::Exception::Type::FAILED which makes kind of sense when looking at the pycapnp code.

Is there a way of achieving this or is it simply not possible?