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

2017-10-29 21:35:05 +08:00
 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

3591 次点击
所在节点    Python
11 条回复
czheo
2017-10-29 21:48:15 +08:00
Nice
hl
2017-10-29 22:29:46 +08:00
为啥不 aiohttp
guyskk0x0
2017-10-29 22:36:40 +08:00
@hl #2 asyncio 太复杂了,curio + requests 学习成本接近 0,并且 API 非常好用
EricCartman
2017-10-29 22:49:03 +08:00
果然不支持 Python 2,现在生产环境还是 Python 2 + Tornado httpclient,
相比 requests 还是蛮难用的
Kilerd
2017-10-29 22:50:30 +08:00
又是你,这个偏爱 curio 的家伙
chenqh
2017-10-29 22:51:45 +08:00
@EricCartman 我也是
czheo
2017-10-29 23:02:21 +08:00
@Kilerd curio 确实比较好用,我被 beazley 说服了。
Kilerd
2017-10-29 23:15:32 +08:00
@czheo 我离不开 uvloop,不然我也不想用 asyncio
czheo
2017-10-30 22:46:04 +08:00
看到 curio 的作者推了你的包。
https://twitter.com/dabeaz/status/924756107117125632
guyskk0x0
2017-10-31 09:21:07 +08:00
@czheo 惊喜,哈哈
dstwhk
2017-11-08 13:50:29 +08:00
很好用的样子

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

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

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

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

© 2021 V2EX