This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Executor.map does not submit futures until iter.next() is called
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bquinlan Nosy List: bquinlan, eric.araujo, python-dev, ysj.ray
Priority: normal Keywords:

Created on 2011-04-06 01:16 by bquinlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg133104 - (view) Author: Brian Quinlan (bquinlan) * (Python committer) Date: 2011-04-06 01:16
from concurrent import futures

with futures.ThreadPoolExecutor(max_workers=5) as e:
  e.map(print, range(10))

# No output
msg133107 - (view) Author: ysj.ray (ysj.ray) Date: 2011-04-06 05:17
Isn't this the supposed behavior?
msg133108 - (view) Author: Brian Quinlan (bquinlan) * (Python committer) Date: 2011-04-06 06:12
I think that it surprising behavior, especially considering that asking for the *first* element in the iterator causes *all* of the futures to be created.
msg133196 - (view) Author: ysj.ray (ysj.ray) Date: 2011-04-07 07:38
Got it. Seems the behavior is not consist with the Executor.map() function:

"The returned iterator raises a TimeoutError if __next__() is called and the result isn't available after timeout seconds from ***the original call to map()***"
msg133197 - (view) Author: Brian Quinlan (bquinlan) * (Python committer) Date: 2011-04-07 08:13
Nice catch. I hadn't noticed that the docs are lying :-)
msg133270 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-07 22:30
New changeset 126353bc7e94 by Brian Quinlan in branch 'default':
Issue #11777: Executor.map does not submit futures until iter.next() is called
http://hg.python.org/cpython/rev/126353bc7e94
msg134223 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-21 15:28
Just a bystander remark: when you use present in the commit message and Misc/NEWS entry (like in “Executor.map does not submit futures until iter.next() is called”), I don’t know whether it is the behavior being fixed (“X used to do Y”) or the new, correct behavior (“X now does Z”).
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55986
2011-04-21 15:28:48eric.araujosetnosy: + eric.araujo
messages: + msg134223
2011-04-07 22:33:02bquinlansetstatus: open -> closed
resolution: fixed
2011-04-07 22:30:59python-devsetnosy: + python-dev
messages: + msg133270
2011-04-07 08:13:21bquinlansetmessages: + msg133197
2011-04-07 07:38:05ysj.raysetmessages: + msg133196
2011-04-06 06:12:37bquinlansetmessages: + msg133108
2011-04-06 05:17:14ysj.raysetnosy: + ysj.ray
messages: + msg133107
2011-04-06 01:16:35bquinlancreate