Python: ThreadPoolExecutor: マルチスレッド

1
2
3
4
5
6
7
8
9
    def bind_all(self):
        def _bind(instance):
            instance.bind_to_debt()

        executor = ThreadPoolExecutor(max_workers=4)
        for i in self.all():
            executor.submit(_bind, i)

        executor.shutdown() # 全てのスレッドが終わるのを待つ