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: 'ThreadPoolExecutor' object has no attribute 'map'
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, GBeauregard, zohim
Priority: normal Keywords:

Created on 2021-10-12 10:48 by zohim, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Screenshot 2021-10-13 at 12.45.04.png zohim, 2021-10-13 11:45
Messages (5)
msg403723 - (view) Author: Zohim Chandani (zohim) Date: 2021-10-12 10:48
import concurrent.futures 
import time 


start = time.perf_counter()

def do_something(seconds):
    print(f'sleeping for {seconds}s ... ')
    time.sleep(seconds)
    return f'done sleeping {seconds} '


with concurrent.futures.ThreadPoolExecutor() as executor: 

    secs = [5,4,3,2,1]
    
    results = executor.map(do_something, secs)

    for result in results: 
        print(result)




finish = time.perf_counter()

print(f'finished in {round(finish-start, 2)} seconds')



The above code yields an attribute error whereas it used to execute perfectly before. Did the method get removed?
msg403761 - (view) Author: Gregory Beauregard (GBeauregard) * Date: 2021-10-12 21:51
I get no attribute error with this code in 3.9 or 3.10.
msg403824 - (view) Author: Zohim Chandani (zohim) Date: 2021-10-13 11:45
Please see attached. I have printed out the python version. Running this on VS code.
msg403966 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-10-15 00:08
I was also unable to replicate on any of 3.7-3.11, including 3.9.6. Is it possible that one of your Python stdlib source files was modified? Does this still happen with a fresh install of Python?

Does your problem still happen if you run the file using a python executable directly rather than using IPython/Jupyter? If it's just a problem with Jupyter, this bug report belongs there.

Can you run:

>>> from concurrent.futures import ThreadPoolExecutor as TPE
>>> TPE.__mro__
(<class 'concurrent.futures.thread.ThreadPoolExecutor'>, <class 'concurrent.futures._base.Executor'>, <class 'object'>)
>>> TPE.__mro__[1]
<class 'concurrent.futures._base.Executor'>
>>> dir(TPE.__mro__[1])
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'map', 'shutdown', 'submit']
msg405276 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-10-28 21:23
It's been a couple of weeks, so I'm closing this. Feel free to re-open if you figure out that this is a bug that you can reliably reproduce on a fresh install of cpython.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89606
2021-10-28 21:23:53Dennis Sweeneysetstatus: pending -> closed
resolution: not a bug
messages: + msg405276

stage: resolved
2021-10-15 00:11:30Dennis Sweeneysetstatus: open -> pending
type: crash -> behavior
components: + Library (Lib)
2021-10-15 00:08:23Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg403966
2021-10-13 11:45:37zohimsetfiles: + Screenshot 2021-10-13 at 12.45.04.png

messages: + msg403824
2021-10-12 21:51:11GBeauregardsetnosy: + GBeauregard
messages: + msg403761
2021-10-12 10:48:59zohimcreate