multiprocessing: Add true async proof-test.

pull/118/head
Paul Sokolovsky 2014-05-01 10:44:22 +03:00
rodzic cd2774bb8e
commit c2f094e29b
1 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -15,6 +15,27 @@ def f2(x):
future = pool.apply_async(f2, (10,))
while not future.ready():
print("not ready")
time.sleep(0.1)
time.sleep(0.2)
print(future.get())
t = time.time()
futs = [
pool.apply_async(f2, (10,)),
pool.apply_async(f2, (11,)),
pool.apply_async(f2, (12,)),
]
while True:
#not all(futs):
c = 0
for f in futs:
if not f.ready():
c += 1
if not c:
break
print("not ready2")
time.sleep(0.2)
print("Run 3 parallel sleep(1)'s in: ", time.time() - t)