Message327865
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] |
|
Date |
User |
Action |
Args |
2018-10-17 06:29:21 | xtreak | set | recipients:
+ xtreak, pitrou, Raz Manor |
2018-10-17 06:29:21 | xtreak | set | messageid: <1539757761.82.0.788709270274.issue34996@psf.upfronthosting.co.za> |
2018-10-17 06:29:21 | xtreak | link | issue34996 messages |
2018-10-17 06:29:21 | xtreak | create | |
|