| 32 | struct python_executor |
| 33 | { |
| 34 | python_executor(py::object loop = ::get_loop()) noexcept |
| 35 | : m_ptr(loop.ptr()) |
| 36 | { |
| 37 | // the asio::execution_context needs to present, we put it into the event loop. |
| 38 | if (!py::hasattr(loop, "__asio_execution_context")) |
| 39 | { |
| 40 | auto ptr = std::make_unique<asio::execution_context>(); |
| 41 | context_ = ptr.get(); |
| 42 | py::setattr(loop, "__asio_execution_context", |
| 43 | py::cast(std::move(ptr))); |
| 44 | } |
| 45 | else |
| 46 | context_ = py::cast<std::unique_ptr<asio::execution_context>&>( |
| 47 | py::getattr(loop, "__asio_execution_context") |
| 48 | ).get(); |
| 49 | } |
| 50 | |
| 51 | asio::execution_context &query(asio::execution::context_t) const |
| 52 | { |