![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
异步编程
文章平均质量分 61
micromicrofat
Python | Go | Deep Learning
展开
-
【Py】关于aiohttp的一段示例代码
"""Comparison of fetching web pages sequentially vs. asynchronouslyRequirements: Python 3.5+, Requests, aiohttp, cchardetFor a walkthrough see this blog post:http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/"""import asynciofrom原创 2022-01-12 17:36:12 · 142 阅读 · 0 评论 -
基于Python3多进程(多线程)+多协程的数据并发处理模版
上一篇文章《基于Python3单进程+多线程+多协程的生产者-消费者模型示例代码》介绍了如何使用Python在单进程的情况下利用协程并发地处理数据,由于Python的GIL,所有代码只利用到了一个CPU核心,无法发挥多核心优势,所以我又做了一个多进程+多协程的模板,这里的代码不涉及具体业务。代码地址:https://github.com/MacwinWin/multiprocessing_asyncio_data_processing总览这里用到的库包括Python3自己的multiprocessin原创 2021-01-31 16:28:48 · 881 阅读 · 0 评论 -
基于Python3单进程+多线程(伪)+多协程的生产者-消费者模型示例代码
import asynciofrom threading import Threadimport timedef 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 · 328 阅读 · 1 评论 -
macOS安装zeromq
操作系统:macOS Big SurPython版本:3.8.2>>> pip3 install pyzmqDefaulting to user installation because normal site-packages is not writeableLooking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting pyzmq Downloading https://pypi.tuna..原创 2020-11-30 14:57:05 · 1886 阅读 · 0 评论 -
V2EX上关于python多线程、协程的性能讨论
https://www.v2ex.com/t/696184转载 2020-11-06 16:38:08 · 209 阅读 · 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 · 196 阅读 · 0 评论 -
通过一个例子分析python3异步编程过程
以下代码来源于:https://www.pythonf.cn/read/99110import asyncioimport timenow = 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 · 2257 阅读 · 0 评论