MCPcopy Create free account
hub / github.com/apache/arrow / BindFuture

Function BindFuture

python/pyarrow/src/arrow/python/async.h:44–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42/// result of the future to a Python object.
43template <typename T, typename PyWrapper = PyObject* (*)(T)>
44void 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

Callers

nothing calls this directly

Calls 4

SafeCallIntoPythonVoidFunction · 0.85
WrapResultFunction · 0.85
CheckPyErrorFunction · 0.85
AddCallbackMethod · 0.45

Tested by

no test coverage detected