kopia lustrzana https://github.com/micropython/micropython-lib
multiprocessing: Add true async proof-test.
rodzic
cd2774bb8e
commit
c2f094e29b
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue