[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-10-12 Thread STINNER Victor
STINNER Victor added the comment: Cool, my threading change works as expected! The name of the target function was logged in bpo-41739 issue. https://buildbot.python.org/all/#/builders/509/builds/172 0:00:28 load avg: 3.58 [ 36/424/1] test_logging failed (env changed) Warning --

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-23 Thread STINNER Victor
STINNER Victor added the comment: I merged my change with "Thread-1 (func)" format: add the target name, but keep "Thread-3" to distinguish two different threads with the same target name. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-23 Thread STINNER Victor
STINNER Victor added the comment: New changeset 98c16c991d6e70a48f4280a7cd464d807bdd9f2b by Victor Stinner in branch 'master': bpo-41833: threading.Thread now uses the target name (GH-22357) https://github.com/python/cpython/commit/98c16c991d6e70a48f4280a7cd464d807bdd9f2b --

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-23 Thread STINNER Victor
STINNER Victor added the comment: > Ideally, I would prefer separate counters for different names IMO if you want to go at the level of details, I suggest you to generate yourself thread names: threads = [threading.Thread(name=f"MyThread-{i}") for i in range(1, 6)] Maintaining a list of

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Ideally, I would prefer separate counters for different names, and omitting a number for the first thread with unique name: doit doit-2 Thread-1 Thread-2 print print-2 doit-3 But it is not feasible. It would require supporting a cache which

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-23 Thread STINNER Victor
STINNER Victor added the comment: I rewrote my PR to generate names like "Thread-3 (func)", rather than just "func". So if two target functions have the same name, or if two threads use the same target, it remains possible to distinguish the two threads. --

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread Ammar Askar
Ammar Askar added the comment: Having the target in the thread name definitely seems like a good idea and would help ease debugging, not just for our tests but when printing thread objects in general. I would agree with the suggestion of placing the counter in there for when multiple

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-15500 "Python should support exporting thread names to the OS". -- ___ Python tracker ___

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor
STINNER Victor added the comment: > And what if run different threads with the same target or with different > targets with the same name? If multiple Thread objects using the same target (or different targets with the same name), they all get the same name using my PR 22357. > Would not

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: And what if run different threads with the same target or with different targets with the same name? Would not "Thread-3" be more useful in this case? for i in range(10): Thread(target=print, args=(i,)).start() for i in range(10): def doit(i=i):

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +21395 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22357 ___ Python tracker ___

[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor
New submission from STINNER Victor : When debugging race conditions in a multithreaded application with many threads, it's hard to debug when threads have generic names like "Thread-3". I propose to use the target name in threading.Thread constructor if the name parameter is omitted. See