| 42 | /// result of the future to a Python object. |
| 43 | template <typename T, typename PyWrapper = PyObject* (*)(T)> |
| 44 | void BindFuture(Future<T> future, PyObject* py_cb, PyWrapper py_wrapper) { |
| 45 | Py_INCREF(py_cb); |
| 46 | OwnedRefNoGIL cb_ref(py_cb); |
| 47 | |
| 48 | auto future_cb = [cb_ref = std::move(cb_ref), |
| 49 | py_wrapper = std::move(py_wrapper)](Result<T> result) { |
| 50 | SafeCallIntoPythonVoid([&]() { |
| 51 | OwnedRef py_value_or_exc{WrapResult(std::move(result), std::move(py_wrapper))}; |
| 52 | Py_XDECREF( |
| 53 | PyObject_CallFunctionObjArgs(cb_ref.obj(), py_value_or_exc.obj(), NULLPTR)); |
| 54 | ARROW_WARN_NOT_OK(CheckPyError(), "Internal error in async call"); |
| 55 | }); |
| 56 | }; |
| 57 | future.AddCallback(std::move(future_cb)); |
| 58 | } |
| 59 | |
| 60 | } // namespace arrow::py |
nothing calls this directly
no test coverage detected