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: Expose max_queue_size in ThreadPoolExecutor
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jim Fasarakis-Hilliard, davin, iforapsy, pitrou, prayerslayer, python-dev, rhettinger, stephen.oneal.04, tianc777, tomMoral, xiang.zhang
Priority: normal Keywords: patch

Created on 2017-02-17 22:10 by prayerslayer, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 143 closed prayerslayer, 2017-02-17 22:10
PR 23864 closed python-dev, 2020-12-20 02:27
PR 23865 closed tianc777, 2020-12-20 02:40
Messages (6)
msg288043 - (view) Author: prayerslayer (prayerslayer) * Date: 2017-02-17 22:10
Hi!

I think the ThreadPoolExecutor should allow to set the maximum size of the underlying queue.

The situation I ran into recently was that I used ThreadPoolExecutor to parallelize AWS API calls; I had to move data from one S3 bucket to another (~150M objects). Contrary to what I expected the maximum size of the underlying queue doesn't have a non-zero value by default. Thus my process ended up consuming gigabytes of memory, because it put more items into the queue than the threads were able to work off: The queue just kept growing. (It ran on K8s and the pod was rightfully killed eventually.)

Of course there ways to work around this. One could use more threads, to some extent. Or you could use your own queue with a defined maximum size. But I think it's more work for users of Python than necessary.
msg289082 - (view) Author: prayerslayer (prayerslayer) * Date: 2017-03-06 09:33
Hello again, there's a reviewed PR open for this issue and it hasn't even received authoritative feedback yet (ie whether or not you intend to support this feature at all). I would be very happy if a core dev could look over this change before everyone forgets about it :)
msg290253 - (view) Author: prayerslayer (prayerslayer) * Date: 2017-03-24 22:38
Ping. That's really a two-line change, can be easily reviewed in 15 minutes :)
msg290949 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-03-31 23:19
Prayslayer, please don't shove.  Your PR request was responded to by Mariatta so it wasn't ignored.  

Making decisions about API expansions takes a while (making sure it fits the intended use, that it isn't a bug factory itself, that it is broadly useful, that it is the best solution to the problem, that is doesn't complicate the implementation or limit future opportunities, that there are unforeseen problems).   Among the core developers, there are only a couple part-time contributors who are qualified to make these assessments for the multi-processing module (those devs don't include me).
msg314699 - (view) Author: Stephen ONeal (stephen.oneal.04) Date: 2018-03-30 17:27
My project we're going into the underlying _work_queue and blocking adding more elements based on unfinished_tasks to accomplish this, bubbling this up to the API would be a welcome addition.
msg314743 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-03-31 17:06
Please note the PR here has some review comments that need addressing.
Also, it needs its conflicts with git master resolved.

I'm cc'ing Thomas Moreau, who has done a lot of work recently on the concurrent.futures internals.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73781
2021-10-14 21:59:47iforapsysetnosy: + iforapsy
2020-12-20 02:40:45tianc777setnosy: + tianc777
pull_requests: + pull_request22727
2020-12-20 02:27:10python-devsetkeywords: + patch
nosy: + python-dev
pull_requests: + pull_request22726
2018-03-31 17:06:25pitrousetversions: + Python 3.8, - Python 3.7
nosy: + tomMoral

messages: + msg314743

assignee: davin ->
2018-03-31 17:04:32pitroulinkissue14119 superseder
2018-03-30 17:27:23stephen.oneal.04setnosy: + stephen.oneal.04
messages: + msg314699
2017-03-31 23:19:49rhettingersetassignee: davin

messages: + msg290949
nosy: + pitrou, davin, rhettinger
2017-03-31 22:01:46Mariattasetstage: patch review
2017-03-24 22:38:56prayerslayersetmessages: + msg290253
2017-03-06 09:33:15prayerslayersetmessages: + msg289082
2017-02-20 09:19:59xiang.zhangsetnosy: + xiang.zhang
2017-02-18 23:12:56Jim Fasarakis-Hilliardsetnosy: + Jim Fasarakis-Hilliard
2017-02-18 12:32:00Mariattasetcomponents: + Library (Lib)
versions: + Python 3.7
2017-02-17 22:10:23prayerslayercreate