Код: Выделить всё
import concurrent.futures
def f2():
print("hello, f2")
def f1():
print("hello, f1")
executor.submit(f2)
with concurrent.futures.ThreadPoolExecutor(16) as executor:
executor.submit(f1)
Код: Выделить всё
hello, f1
Код: Выделить всё
import concurrent.futures
def f2():
print("hello, f2")
return 3
def f1():
print("hello, f1")
print(executor.submit(f2).result())
with concurrent.futures.ThreadPoolExecutor(16) as executor:
executor.submit(f1)
Код: Выделить всё
import concurrent.futures
def f2():
print("hello, f2")
return 3
def f1():
print("hello, f1")
return executor.submit(f2).result()
with concurrent.futures.ThreadPoolExecutor(16) as executor:
print(executor.submit(f1).result())
Код: Выделить всё
hello, f1
hello, f2
3
Обновление:
Без with, вывод примера 1 является случайным (т.е. иногда выводит hello, f2, а иногда нет)
Подробнее здесь: https://stackoverflow.com/questions/790 ... -submitted