-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
i made a simple Awaitable class in c++ to support pythons async/await syntax with c++ deferred functions:
template<typename ResultType>
class Awaitable : public std::enable_shared_from_this<Awaitable<ResultType>>{
public:
Awaitable();
Awaitable(std::future<ResultType>&);
std::shared_ptr<Awaitable<ResultType>> __iter__();
std::shared_ptr<Awaitable<ResultType>> __await__();
void __next__();
private:
std::future<ResultType> future;
};is this something that would have a chance to land in pybind11?
So, supporting an interface like:
m.def_async("name", &function_returning_a_future);What seems to be missing for this is a StopIteration exception type with templated "return" type.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels