作者x9060000456 (你好)
看板Python
标题[问题] python 非同步问题
时间Wed May 1 13:35:53 2019
Hi 大家好,
小弟最近因为要及时
取得第三方资料做非同步,
第三方资料格式是 json format,
因为 json 资料每层物件又包含多个 arry,
故目前是写三个巢状的 for 回圈针对每层做处理取值,
for i in jsonLayer1:
for i in jsonLayer2:
for i in jsonLayer3:
目前是使用
concurrent.futures.ThreadPoolExecutor 中的
executor.map 放置在上述 3 个回圈,
目前困惑的点效能似乎没有得到优化,
google survey 的结果都是只有执行一个 executor.map,
未看到 executor.map 中的 function 里面再包一个 executor.map,
在感谢版上的大大若有相关资讯提供分享~
若有更好的非同步套件也谢谢分享~~~~~~~
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.163.209.96
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1556688955.A.13A.html
1F:推 lemon651: parse json这种计算密集在python用thread是完全没用的 05/01 14:51
2F:→ lemon651: 你要找的是multiprocessing 05/01 14:51
3F:→ zerof: ProcessPoolExecutor 05/02 10:55