classification
Title: Allow specifying prefix for thread name in concurrent.futures.ThreadPoolExecutor
Type: enhancement Stage: commit review
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: durin42, gregory.p.smith, python-dev
Priority: normal Keywords: patch

Created on 2016-08-01 18:03 by durin42, last changed 2016-08-07 17:20 by gregory.p.smith. This issue is now closed.

Files
File name Uploaded Description Edit
cpython.patch durin42, 2016-08-01 18:03 Initial patch. review
Messages (4)
msg271790 - (view) Author: Augie Fackler (durin42) * Date: 2016-08-01 18:03
This is mostly useful for when you've got a large number of threads and want to try and identify what threadpool is going nuts.
msg272125 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-08-07 17:12
A workaround for this on 3.5 and older versions is probably to do:

initialization:

num_q = queue.Queue()
map(num_q.put, range(max_workers))

Then schedule max_workers identical tasks:

def task():
  threading.current_thread().name = '%s_%d' % (your_prefix, num_q.get())
  num_q.task_done()
  num_q.join()  # block so that this thread cannot take a new thread naming task until all other tasks are complete.  guaranteeing we are executed once per max_workers threads.
msg272126 - (view) Author: Roundup Robot (python-dev) Date: 2016-08-07 17:19
New changeset 1002a1bdc5b1 by Gregory P. Smith in branch 'default':
Issue #27664: Add to concurrent.futures.thread.ThreadPoolExecutor()
https://hg.python.org/cpython/rev/1002a1bdc5b1
msg272127 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2016-08-07 17:20
cleaned up a bit with documentation added and submitted.  thanks.  ThreadPoolExecutor threads now have a default name as well, because why not.
History
Date User Action Args
2016-08-07 17:20:38gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg272127

stage: patch review -> commit review
2016-08-07 17:19:30python-devsetnosy: + python-dev
messages: + msg272126
2016-08-07 17:12:51gregory.p.smithsetmessages: + msg272125
2016-08-01 18:18:13zach.waresetstage: patch review
versions: + Python 3.6
2016-08-01 18:03:49gregory.p.smithsetnosy: + gregory.p.smith
2016-08-01 18:03:16durin42create