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.

Author aeros
Recipients aeros, bquinlan, pitrou
Date 2020-01-17.05:01:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579237298.63.0.667031175149.issue39349@roundup.psfhosted.org>
In-reply-to
Content
As of now, I have the implementation for ThreadPoolExecutor working correctly, and a unit test added to ensure its behavior. It was a bit more involved than I originally anticipated, as I had to make a minor change in the _worker() function to allow the new parameter to be compatible with wait (which is important, as it prevents dangling threads).

With my initial implementation, using "wait=True" and "cancel_futures=True" was resulting in any threads that called work_queue.get(block=True) to hang indefinitely. In order to remedy this, I changed it to use work_queue.get_nowait(). If a queue.Empty exception occurs, it checks for a global constant _cancelling_futures (set to True just in shutdown before it starts draining the work queue). If it's true, the while True loop is broken, otherwise it continues to the next iteration. This effectively has the same behavior as before. 

I experimented with a few different possible solutions, and the above was the only one that worked while still maintaining the current behavior as much as possible. From what I can tell, this was the only viable means of implementing the new parameter without making it entirely incompatible with "wait=True".

At this point, I believe the only remaining step for the ThreadPoolExecutor implementation is to update the documentation and decide on the name. After working with it, I'm leaning more towards *cancel_futures*, as I think this more accurately describes what it does compared to just *cancel* (which is a bit vague IMO).
History
Date User Action Args
2020-01-17 05:01:38aerossetrecipients: + aeros, bquinlan, pitrou
2020-01-17 05:01:38aerossetmessageid: <1579237298.63.0.667031175149.issue39349@roundup.psfhosted.org>
2020-01-17 05:01:38aeroslinkissue39349 messages
2020-01-17 05:01:38aeroscreate