异步编程
文章平均质量分 61
micromicrofat
Python | Go | Deep Learning
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【Py】关于aiohttp的一段示例代码
"""Comparison of fetching web pages sequentially vs. asynchronously Requirements: Python 3.5+, Requests, aiohttp, cchardet For a walkthrough see this blog post: http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/ """ import asyncio from原创 2022-01-12 17:36:12 · 223 阅读 · 0 评论 -
基于Python3多进程(多线程)+多协程的数据并发处理模版
上一篇文章《基于Python3单进程+多线程+多协程的生产者-消费者模型示例代码》介绍了如何使用Python在单进程的情况下利用协程并发地处理数据,由于Python的GIL,所有代码只利用到了一个CPU核心,无法发挥多核心优势,所以我又做了一个多进程+多协程的模板,这里的代码不涉及具体业务。 代码地址:https://github.com/MacwinWin/multiprocessing_asyncio_data_processing 总览 这里用到的库包括Python3自己的multiprocessin原创 2021-01-31 16:28:48 · 1126 阅读 · 0 评论 -
基于Python3单进程+多线程(伪)+多协程的生产者-消费者模型示例代码
import asyncio from threading import Thread import time def start_loop(loop): asyncio.set_event_loop(loop) loop.run_forever() def create(timestamp, worker_pool, worker_loop): worker_pool[timestamp] = {} asyncio.run_coroutine_threadsafe(co原创 2021-01-28 17:50:57 · 426 阅读 · 1 评论 -
macOS安装zeromq
操作系统:macOS Big Sur Python版本:3.8.2 >>> pip3 install pyzmq Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pyzmq Downloading https://pypi.tuna..原创 2020-11-30 14:57:05 · 2421 阅读 · 0 评论 -
V2EX上关于python多线程、协程的性能讨论
https://www.v2ex.com/t/696184转载 2020-11-06 16:38:08 · 312 阅读 · 0 评论 -
python协程学习路径
最近在学习python的协程,将自己在学习过程中遇到的比较好的资料记录下来,希望能帮到更多人 生成器、迭代器、可迭代对象: https://nvie.com/posts/iterators-vs-generators/ asyncio: 英文:https://www.educative.io/blog/python-concurrency-making-sense-of-asyncio 英文:https://realpython.com/async-io-python/ 中文:https://zhuanl原创 2020-10-29 17:52:18 · 244 阅读 · 0 评论 -
通过一个例子分析python3异步编程过程
以下代码来源于:https://www.pythonf.cn/read/99110 import asyncio import time now = lambda: time.time() async def do_some_work(x): print('Waiting: ', x) await asyncio.sleep(x) # 执行sleep时,await使此协程主动让出控制权,loop调用其他协程 return 'Done after {}s'.format(x)原创 2020-10-30 11:53:43 · 2836 阅读 · 0 评论
分享