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 xtreak
Recipients Raz Manor, pitrou, xtreak
Date 2018-10-17.06:29:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539757761.82.0.788709270274.issue34996@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the report. I think using current_thread().name gives thread name with number that is useful. I don't know the exact use case or maybe I am misunderstanding the use case and perhaps adding a script where your PR applies with the output will be helpful. I will resort to feedback from others. Adding Antoine as per the expert index for multiprocessing module. Antoine, feel free to remove yourself if this is irrelevant.


# bpo34720.py

from multiprocessing.pool import ThreadPool

def f(x):
    from threading import current_thread
    print(current_thread().name)
    return x*x

if __name__ == '__main__':
    with ThreadPool(5) as p:
        print(p.map(f, [1, 2, 3]))


$ ./python.exe ../backups/bpo34720.py
Thread-1
Thread-1
Thread-2
[1, 4, 9]


# With PR and name as "custom-name" for ThreadPool

from multiprocessing.pool import ThreadPool

def f(x):
    from threading import current_thread
    print(current_thread().name)
    return x*x

if __name__ == '__main__':
    with ThreadPool(5, name="custom-name") as p:
        print(p.map(f, [1, 2, 3]))

git:(pr_9906) ./python.exe ../backups/bpo34720.py
custom-name-Worker-0
custom-name-Worker-1
custom-name-Worker-2
[1, 4, 9]
History
Date User Action Args
2018-10-17 06:29:21xtreaksetrecipients: + xtreak, pitrou, Raz Manor
2018-10-17 06:29:21xtreaksetmessageid: <1539757761.82.0.788709270274.issue34996@psf.upfronthosting.co.za>
2018-10-17 06:29:21xtreaklinkissue34996 messages
2018-10-17 06:29:21xtreakcreate