Created
November 8, 2019 03:59
-
-
Save ghosx/70a8c8bc37d2fbdda2075a44fc37f947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor | |
class A(object): | |
def __init__(self, name, b_list): | |
self.name = name | |
self.bs = b_list | |
def sign(self): | |
p = ProcessPoolExecutor(4) | |
for i in self.bs: | |
p.submit(i.sign_one) | |
p.shutdown() | |
print("ok") | |
class B(object): | |
def __init__(self, name, ): | |
self.name = name | |
def print(self): | |
print(self.name) | |
time.sleep(3) | |
def sign_one(self): | |
t = ThreadPoolExecutor(5) | |
t.submit(self.print) | |
t.shutdown() | |
if __name__ == '__main__': | |
bb = [B("b1"), B("b2")] | |
aa = A("a1", bb) | |
aa.sign() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment