前锋
风格asyncio渠道。
带有泛型的完整类型,可mypy 。
受的启发。
例子
发送和接收
ch = chan ( int ) # Chan[int]
await ( ch << 2 ) # or use `await ch.send(x)`
two = await ([] << ch ) # or use `await ch.recv()`
assert two == 2
# `ch.close()` is idempotent
await ch . close ()
基本的
if ch :
# if `Chan[T]` is open
len ( ch ) # How many items are in `ch`
async with ch :
# close `ch` after exiting lexical-scope
async
评论0
最新资源