MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / MakeCallback

Function MakeCallback

PythonAPI/carla/source/libcarla/libcarla.cpp:176–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176static auto MakeCallback(boost::python::object callback) {
177 namespace py = boost::python;
178 // Make sure the callback is actually callable.
179 if (!PyCallable_Check(callback.ptr())) {
180 PyErr_SetString(PyExc_TypeError, "callback argument must be callable!");
181 py::throw_error_already_set();
182 }
183
184 // We need to delete the callback while holding the GIL.
185 using Deleter = carla::PythonUtil::AcquireGILDeleter;
186 auto callback_ptr = carla::SharedPtr<py::object>{new py::object(callback), Deleter()};
187
188 // Make a lambda callback.
189 return [callback=std::move(callback_ptr)](auto message) {
190 carla::PythonUtil::AcquireGIL lock;
191 try {
192 py::call<void>(callback->ptr(), py::object(message));
193 } catch (const py::error_already_set &) {
194 PyErr_Print();
195 }
196 };
197}
198
199#include "Geom.cpp"
200#include "Occupancy.cpp"

Callers 2

SubscribeToStreamFunction · 0.85
OnTickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected