0
[OK]を、私はこのコードを持っていると言う:Python 3のマルチプロセッシングプールで2つの異なる機能を実行するには?
import time
def helloworld(sleep_time):
while True:
time.sleep(sleep_time)
print('Hello world!')
def hellocountry():
while True:
time.sleep(60)
print('Hello country!')
if __name__ == '__main__':
with Pool(3) as p:
p.map(helloworld, [1, 5, 7])
のHelloWorldが実行されている間、どのように私は、hellocountryを実行しますか?私はラッパー関数を書くことができたと思うが、それはやや不器用で不快なようだ。
使用[ '.submit()'](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.submit)(私が提案し ' helloworld() 'も呼び出す)。 – Elazar
Pool()はThreadPoolExecutorの周りのラッパーにすぎませんか? – user6769219
あなたのコードでは、 'Pool'は未定義です。しかし、いいえ、私は 'Pool'とExecutorを混乱させました。 – Elazar