1 Star 5 Fork 3

Paul / asyncio_demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
3.3_await2.py 552 Bytes
一键复制 编辑 原始数据 按行查看 历史
Paul 提交于 2020-06-26 01:33 . 首次提交
# -*- encoding: utf-8 -*-
"""
@Time : 2020/6/25
@Author : hongboli
"""
import asyncio
async def others():
print('开始')
await asyncio.sleep(3)
print('结束')
return '返回值'
async def func():
print('执行协程函数内部代码')
# 遇到IO操作挂起当前协程(任务),等IO操作完成之后再继续往下执行。当前协程挂起时,事件循环可以去执行其他的协程(任务)
response = await others()
print('IO请求结束,结果为:', response)
asyncio.run(func())
Python
1
https://gitee.com/paultest/asyncio_demo.git
git@gitee.com:paultest/asyncio_demo.git
paultest
asyncio_demo
asyncio_demo
master

搜索帮助