Make Message property accessors copy

The default references, which breaks because Message gets reused, so
storing `.conn` gives you something that changes the next time a worker
gets a message.
This commit is contained in:
Jason Rhinelander 2021-12-03 13:08:11 -04:00
parent f1160d0a25
commit 4136c29d06
No known key found for this signature in database
GPG key ID: C4992CE7A88D4262

View file

@ -153,11 +153,13 @@ This typically protects administrative commands like shutting down or access to
msg msg
.def_property_readonly("is_reply", [](const Message& m) { return !m.reply_tag.empty(); }, .def_property_readonly("is_reply", [](const Message& m) { return !m.reply_tag.empty(); },
"True if this message is expecting a reply (i.e. it was received on a request_command endpoint)") "True if this message is expecting a reply (i.e. it was received on a request_command endpoint)")
.def_readonly("remote", &Message::remote, R"(Some sort of remote address from which the request came. .def_readonly("remote", &Message::remote, py::return_value_policy::copy,
R"(Some sort of remote address from which the request came.
Typically the IP address string for TCP connections and "localhost:UID:GID:PID" for unix socket IPC connections.)") Typically the IP address string for TCP connections and "localhost:UID:GID:PID" for unix socket IPC connections.)")
.def_readonly("conn", &Message::conn, "The connection ID info for routing a reply") .def_readonly("conn", &Message::conn, py::return_value_policy::copy,
.def_readonly("access", &Message::access, "The connection ID info for routing a reply")
.def_readonly("access", &Message::access, py::return_value_policy::copy,
"The access level of the invoker (which can be higher than the access level required for the command category") "The access level of the invoker (which can be higher than the access level required for the command category")
.def("dataview", [](const Message& m) { .def("dataview", [](const Message& m) {
py::list l; py::list l;