classification
Title: 'ThreadPoolExecutor' object has no attribute 'map'
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: pending Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, GBeauregard, zohim
Priority: normal Keywords:

Created on 2021-10-12 10:48 by zohim, last changed 2021-10-15 00:11 by Dennis Sweeney.

Files
File name Uploaded Description Edit
Screenshot 2021-10-13 at 12.45.04.png zohim, 2021-10-13 11:45
Messages (4)
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 triager) 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']
History
Date User Action Args
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