async with reporter() as r: async def some_thing() try: await foo() except BaseException as e: r.report(e) ...
async with report_crashes(): ...which captures and reports on a wide range of errors. It's actually outside the our cancel scope so we don't normally need shielding but we don't have control over how the user is running their event loop so there may be a cancel scope outside of our code and we need to report that failure still.
s, r = anyio.create_memory_object_stream(float('inf'), item_type=str) bt = BufferedTextReceiveStream(r) with s, r: await s.send("foo") assert await bt.receive() == "foo" await s.send("bar") assert await bt.receive_exactly(1) == "b" assert await bt.receive_exactly(2) == "ar" await s.send("baz") assert await bt.receive_until("a", 100) == "b" assert await bt.receive_exactly(1) == "z"
unused_tcp_portfixture. Which I'm not sure why it exists there... But is it interesting for AnyIO to have it as well?