Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 834a57e

Browse files
committed
Fix inheriting from Sendable
- initSendable needs to be passed a reference - The SendableRegistry needs to be cleared on shutdown to ensure that ntcore doesn't call into python
1 parent 7022310 commit 834a57e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

gen/Sendable.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ classes:
88
shared_ptr: true
99
methods:
1010
InitSendable:
11+
virtual_xform: |
12+
[&](py::function fn) {
13+
auto builderHandle = py::cast(builder, py::return_value_policy::reference);
14+
fn(builderHandle);
15+
}

wpiutil/src/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@
44
void setup_stack_trace_hook(py::object fn);
55
void cleanup_stack_trace_hook();
66

7+
namespace wpi::impl {
8+
void ResetSendableRegistry();
9+
} // namespace wpi::impl
10+
711
RPYBUILD_PYBIND11_MODULE(m) {
812
initWrapper(m);
913

1014
static int unused;
11-
py::capsule cleanup(&unused, [](void *) { cleanup_stack_trace_hook(); });
15+
py::capsule cleanup(&unused, [](void *) {
16+
{
17+
py::gil_scoped_release unlock;
18+
wpi::impl::ResetSendableRegistry();
19+
}
20+
21+
cleanup_stack_trace_hook();
22+
});
1223

1324
m.def("_setup_stack_trace_hook", &setup_stack_trace_hook);
1425
m.add_object("_st_cleanup", cleanup);

0 commit comments

Comments
 (0)