Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-29842: Make Executor.map less eager so it handles large/unbounded…#18566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
graingert commented Feb 20, 2020 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
… input iterables appropriately
…lds no reference to result at the moment it yields Reduce line lengths to PEP8 limits
rdarder left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there! sorry for intruding. I was looking for this feature and decided to try this patch out. Works great! Just found a small issue so I sent you a comment.
Thank you!
| except StopIteration: | ||
| argsiter = None | ||
| else: | ||
| fs.append(self.submit(fn, *args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the executor has been shut down, this will raise:cannot schedule new futures after shutdown
But, also the base executor holds no state, so at this level it'll be pretty hard to tell if the executor has been shut down or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdarder
this could catch that RuntimeError and just return, or the executor could keep a weakset of result_iterators and close them on shutdown
Doc/library/concurrent.futures.rst Outdated
| .. versionchanged:: 3.5 | ||
| Added the *chunksize* argument. | ||
| .. versionchanged:: 3.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. versionchanged:: 3.9 | |
| .. versionchanged:: 3.11 |
Uh oh!
There was an error while loading. Please reload this page.
Tronic commented Oct 29, 2021
While waiting for this to be included in Python, one can easily copy&paste the map function out of this version and call it with the executor as the first argument. Hoping that you get this merged soon! |
Uh oh!
There was an error while loading. Please reload this page.
kumaraditya303 commented Jul 23, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@graingert Tests are failing, can you fix them and rebase to main? I'll then review and run through the buildbots. |
Misc/NEWS.d/next/Library/2019-05-06-12-49-21.bpo-29842.Tw-ETh.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
| yield fs.pop().result() | ||
| res = fs.popleft().result() | ||
| else: | ||
| yield fs.pop().result(end_time - time.monotonic()) |
graingertJul 23, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't cancel the currently waited on fut correctly: #95166
importcontextlibimportfunctoolsimportconcurrent.futuresimportthreadingimportsysdeffn(num, stop_event): ifnum==1: stop_event.wait() return"done 1"ifnum==2: return"done 2"defmain(): stop_event=threading.Event() log= [] withconcurrent.futures.ThreadPoolExecutor(max_workers=1) aspool: defprint_n_wait(ident): log.append(f"{ident=} started") try: stop_event.wait() finally: log.append(f"{ident=} stopped") fut=pool.submit(print_n_wait, ident="first") try: withcontextlib.closing(pool.map(print_n_wait, ["second", "third"], timeout=1)) asgen: try: next(gen) exceptconcurrent.futures.TimeoutError: print("timed out") else: raiseRuntimeError("timeout expected") finally: stop_event.set() assertlog== ["ident='first' started", "ident='first' stopped"], f"{log=} is wrong"if__name__=="__main__": sys.exit(main())kumaraditya303 commented Jul 23, 2022
@graingert You can run |
Jason-Y-Z commented Feb 3, 2024
Hey all, I took the inspiration from this PR and continued the work in #114975 |
ebonnal commented Oct 17, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Hi, fyi here is a follow up PR: #125663 🙏🏻 |
… input iterables appropriately
bugs.python.org/issue29842
bugs.python.org/issue29842
recreate of #707 with conflicts fixed and versionchanged updated to py3.9
/cc @MojoVampire
https://bugs.python.org/issue29842