#- * -コーディング:UTF-8 - * - #1 @date:2017年8月26日 #@Original: #のマルチプロセス・ インポートitertools から concurrent.futures インポートProcessPoolExecutor 結果 = [] #のadd_done_callbackでタスクを完了するためのコールバック関数の呼び出し DEFのwhen_done(R): #主要プロセスで実行when_done result.append(r.result()) " "" :コンテキストマネージャCLASS_A()ASと """ プールとしてProcessPoolExecutor()を持つ: のため keep_stock_threshold、buy_change_threshold 中\ itertools.product(keep_stock_list、buy_change_list): 「」 " 別のプロセスの提出を通じて提出カルク機能とパラメータを使用します。タスクを送信するために提出する 簡単な関数、クラスメソッド、閉鎖や他のサポートされていないプロセスに平行でなければなりません送信されたジョブ の互換性ピクルスのシリアライズでなければなりません関数の引数と戻り値を、プロセス間を通信ニーズ "" " future_result = pool.submit(CALC、keep_stock_threshold、 buy_change_threshold) #プロセスはカルクの実行されるコールバック関数の終了後に終了する future_result.add_done_callback(when_done) 印刷(ソートされた(結果を)[:: - 1] [ :10 ]) #マルチスレッド から concurrent.futuresがインポートThreadPoolExecutorの 結果 = [] DEFwhen_done(R): result.appendを(r.result()) ThreadPoolExecutor(max_workers持つ = 8 )プールとして: のため keep_stock_threshold、buy_change_threshold で\ itertools.product(keep_stock_list、buy_change_list): future_result = pool.submit(CALC、keep_stock_threshold、 buy_change_threshold) future_result.add_done_callback(when_done)