Warning, file /jana2/src/python/externals/pybind11-2.10.3/tests/test_async.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "pybind11_tests.h"
0011
0012 TEST_SUBMODULE(async_module, m) {
0013 struct DoesNotSupportAsync {};
0014 py::class_<DoesNotSupportAsync>(m, "DoesNotSupportAsync").def(py::init<>());
0015 struct SupportsAsync {};
0016 py::class_<SupportsAsync>(m, "SupportsAsync")
0017 .def(py::init<>())
0018 .def("__await__", [](const SupportsAsync &self) -> py::object {
0019 static_cast<void>(self);
0020 py::object loop = py::module_::import("asyncio.events").attr("get_event_loop")();
0021 py::object f = loop.attr("create_future")();
0022 f.attr("set_result")(5);
0023 return f.attr("__await__")();
0024 });
0025 }