Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Executor Objects
with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(pow, 323, 1235)
print(future.result())

# Note: calling future.result() outside this with statement would work fine,
# but calling it here is safe because we print it immediately and the executor
# can complete the task before the context manager exits.
.. method:: map(fn, *iterables, timeout=None, chunksize=1, buffersize=None)

Similar to :func:`map(fn, *iterables) <map>` except:
Expand Down Expand Up @@ -151,8 +153,10 @@ And::
print(f.result())

executor = ThreadPoolExecutor(max_workers=1)
executor.submit(wait_on_future)

executor.submit(wait_on_future).result()
# Note: calling future.result() here would cause a deadlock because the single
# worker thread is already executing wait_on_future(), which itself is waiting
# for a result from the same executor.

.. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())

Expand Down
Loading