test_async.cpp
Go to the documentation of this file.
1 /*
2  tests/test_async.cpp -- __await__ support
3 
4  Copyright (c) 2019 Google Inc.
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #include "pybind11_tests.h"
11 
12 TEST_SUBMODULE(async_module, m) {
13  struct DoesNotSupportAsync {};
14  py::class_<DoesNotSupportAsync>(m, "DoesNotSupportAsync").def(py::init<>());
15  struct SupportsAsync {};
16  py::class_<SupportsAsync>(m, "SupportsAsync")
17  .def(py::init<>())
18  .def("__await__", [](const SupportsAsync &self) -> py::object {
19  static_cast<void>(self);
20  py::object loop = py::module_::import("asyncio.events").attr("get_event_loop")();
21  py::object f = loop.attr("create_future")();
22  f.attr("set_result")(5);
23  return f.attr("__await__")();
24  });
25 }
Matrix3f m
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
TEST_SUBMODULE(async_module, m)
Definition: test_async.cpp:12


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45