[問題] python 非同步問題

看板Python作者 (你好)時間6年前 (2019/05/01 13:35), 編輯推噓1(102)
留言3則, 2人參與, 6年前最新討論串1/1
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://www.ptt.cc/bbs/Python/M.1556688955.A.13A.html

05/01 14:51, 6年前 , 1F
parse json這種計算密集在python用thread是完全沒用的
05/01 14:51, 1F

05/01 14:51, 6年前 , 2F
你要找的是multiprocessing
05/01 14:51, 2F

05/02 10:55, 6年前 , 3F
ProcessPoolExecutor
05/02 10:55, 3F
文章代碼(AID): #1SoJ0x4w (Python)
文章代碼(AID): #1SoJ0x4w (Python)