Curio + Requests: Async HTTP for Humans 和 Requests 一样的味道

2017 年 10 月 29 日
 guyskk0x0

$ pip install curequests

from curio import run
from curequests import get, post

async def main():
    r = await get('https://httpbin.org/get')
    print(r.json())
    r = await post('https://httpbin.org/post', json={'hello': 'world'})
    print(r.json())

run(main)

和 Requests 一样的味道,请参考 Requests 文档 食用!
Github: https://github.com/guyskk/curequests

4332 次点击
所在节点    Python
11 条回复
czheo
2017 年 10 月 29 日
Nice
hl
2017 年 10 月 29 日
为啥不 aiohttp
guyskk0x0
2017 年 10 月 29 日
@hl #2 asyncio 太复杂了,curio + requests 学习成本接近 0,并且 API 非常好用
EricCartman
2017 年 10 月 29 日
果然不支持 Python 2,现在生产环境还是 Python 2 + Tornado httpclient,
相比 requests 还是蛮难用的
Kilerd
2017 年 10 月 29 日
又是你,这个偏爱 curio 的家伙
simple2025
2017 年 10 月 29 日
@EricCartman 我也是
czheo
2017 年 10 月 29 日
@Kilerd curio 确实比较好用,我被 beazley 说服了。
Kilerd
2017 年 10 月 29 日
@czheo 我离不开 uvloop,不然我也不想用 asyncio
czheo
2017 年 10 月 30 日
看到 curio 的作者推了你的包。
https://twitter.com/dabeaz/status/924756107117125632
guyskk0x0
2017 年 10 月 31 日
@czheo 惊喜,哈哈
dstwhk
2017 年 11 月 8 日
很好用的样子

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/401739

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX