black formatting
This commit is contained in:
parent
d528285828
commit
11f98d078f
|
@ -6,7 +6,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
|
|
||||||
def add_one(number):
|
def add_one(number):
|
||||||
print(number)
|
print(number)
|
||||||
sleep(randint(0,2))
|
sleep(randint(0, 2))
|
||||||
return number + 1
|
return number + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ from concurrent.futures import ThreadPoolExecutor, Future
|
||||||
|
|
||||||
results: list[int] = []
|
results: list[int] = []
|
||||||
|
|
||||||
|
|
||||||
def add_one(number: int) -> int:
|
def add_one(number: int) -> int:
|
||||||
sleep(randint(0,2))
|
sleep(randint(0, 2))
|
||||||
result = number + 1
|
result = number + 1
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
def add_one(number):
|
def add_one(number):
|
||||||
print(number)
|
print(number)
|
||||||
sleep(randint(0,2))
|
sleep(randint(0, 2))
|
||||||
return number + 1
|
return number + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@ from concurrent.futures import ThreadPoolExecutor, Future, wait, FIRST_COMPLETED
|
||||||
|
|
||||||
results: list[int] = []
|
results: list[int] = []
|
||||||
|
|
||||||
|
|
||||||
def add_one(number: int) -> int:
|
def add_one(number: int) -> int:
|
||||||
sleep(randint(0,2))
|
sleep(randint(0, 2))
|
||||||
return number + 1
|
return number + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ from concurrent.futures import ThreadPoolExecutor, wait, Future
|
||||||
|
|
||||||
results: list[int] = []
|
results: list[int] = []
|
||||||
|
|
||||||
|
|
||||||
def add_one(number: int) -> int:
|
def add_one(number: int) -> int:
|
||||||
print(number)
|
print(number)
|
||||||
sleep(randint(0,2))
|
sleep(randint(0, 2))
|
||||||
return number + 1
|
return number + 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +29,9 @@ def main() -> None:
|
||||||
print("All done!")
|
print("All done!")
|
||||||
|
|
||||||
with ThreadPoolExecutor() as executor:
|
with ThreadPoolExecutor() as executor:
|
||||||
futures: list[Future] = [executor.submit(add_one, number) for number in range(10)]
|
futures: list[Future] = [
|
||||||
|
executor.submit(add_one, number) for number in range(10)
|
||||||
|
]
|
||||||
print("Done waiting!")
|
print("Done waiting!")
|
||||||
for future in futures:
|
for future in futures:
|
||||||
print(future.result())
|
print(future.result())
|
||||||
|
|
Loading…
Reference in New Issue