2
0
mirror of https://github.com/boostorg/cobalt.git synced 2026-01-19 04:02:16 +00:00
Files
cobalt/example/python.py
Klemens Morgenstern 45901641ac renamed to cobalt.
2023-10-16 21:42:07 +08:00

21 lines
492 B
Python

# run from the build folder
import asyncio
import boost_cobalt_example_python
async def my_cor():
return "foobar"
async def use_cpp():
#test awaiting C++ primitives
async for item in boost_async_example_python.test_generator():
print("Cpp generator", item)
print("Cpp promise gave us", await boost_async_example_python.test_promise())
# having C++ await our python coros
await boost_async_example_python.test_py_promise(my_cor())
asyncio.run(use_cpp())