classification
Title: Add "daemon" argument to threading.Thread constructor
Type: feature request Stage:
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: jnoller Nosy List: asksol, conf, jnoller, pitrou, ptn, rhettinger, tebeka (7)
Priority: Keywords easy, patch

Created on 2009-05-19 19:14 by tebeka, last changed 2009-11-21 15:32 by asksol.

Files
File name Uploaded Description Edit Remove
threading.diff tebeka, 2009-05-20 22:52 Patch
threading.diff tebeka, 2009-06-17 16:20 Diff againt r73465
threading.py ptn, 2009-06-17 17:34
threading3k.diff tebeka, 2009-06-17 17:52 Diff
6064-multiprocessing-daemon-kwarg.patch asksol, 2009-11-21 15:32 Patch for multiprocessing
Messages (15)
msg88088 - (view) Author: Miki Tebeka (tebeka) Date: 2009-05-19 19:13
It would be nice if threading.Thread constructor will have a "daemon"
argument as well.

This way we'll be able to write
    Thread(target=some_function, daemon=1).start()

Instead of currently writing
    t = Thread(target=some_function)
    t.daemon = True
    t.start()
msg88094 - (view) Author: Raymond Hettinger (rhettinger) Date: 2009-05-19 19:39
+1
msg88142 - (view) Author: Miki Tebeka (tebeka) Date: 2009-05-20 22:52
Attaching a patch against trunk (at revision 72805).
msg88169 - (view) Author: Miki Tebeka (tebeka) Date: 2009-05-21 21:27
I think that 
    self.__daemonic = daemon or self._set_daemon()
is wrong, need to thing about it.
msg89465 - (view) Author: Pablo Torres Navarrete (ptn) Date: 2009-06-17 15:51
+1, but I can't apply the patch cleanly:

$ patch -p0 < threading.diff
patching file Doc/library/threading.rst
Hunk #1 succeeded at 198 (offset -17 lines).
Hunk #2 succeeded at 211 (offset -17 lines).
Hunk #3 succeeded at 230 (offset -17 lines).
patching file Lib/threading.py
Hunk #1 succeeded at 407 with fuzz 1 (offset -16 lines).
Hunk #2 FAILED at 416.
1 out of 2 hunks FAILED -- saving rejects to file Lib/threading.py.rej
patching file Lib/test/test_threading.py
Hunk #1 succeeded at 350 with fuzz 2 (offset 14 lines).
msg89467 - (view) Author: Miki Tebeka (tebeka) Date: 2009-06-17 16:20
I'm attaching a new diff (svn diff > threading.diff), hope this one's OK.
msg89470 - (view) Author: Pablo Torres Navarrete (ptn) Date: 2009-06-17 17:34
Nope.  Our working copies seem to be different.  I'm uploading mine, 
which I just update to revision 73468.  Please diff yours against that 
and against HEAD too, just in case.

Hunk 2 on threading.py fails because your attributes use two leading 
underscores and mine use only one.  I have no idea why hunk4 fails.
msg89471 - (view) Author: Miki Tebeka (tebeka) Date: 2009-06-17 17:38
I'm diffing against the 2.7 branch, I guess your comes from the 3.2?

Will checkout 3.2 and do it there as well.
msg89472 - (view) Author: Miki Tebeka (tebeka) Date: 2009-06-17 17:52
Attaching a diff against the py3k branch on revision 73468
msg89473 - (view) Author: Pablo Torres Navarrete (ptn) Date: 2009-06-17 18:12
> I'm diffing against the 2.7 branch, I guess your comes from the 3.2?
*forehead meets desktop*

Patch applies cleanly and all tests pass.  I used it for a while and 
everything seemed OK.  After someone else tests, I say we go for it :)
msg89474 - (view) Author: Lucas Prado Melo (conf) Date: 2009-06-17 18:12
+1 to the py3k diff. :)
Hey, I think this daemon property should be set as a keyword argument of
the Thread constructor.
msg89475 - (view) Author: Pablo Torres Navarrete (ptn) Date: 2009-06-17 18:23
+1 on making it a keyword-only argument.
msg89481 - (view) Author: Antoine Pitrou (pitrou) Date: 2009-06-17 21:14
+1 from me as well.
msg89836 - (view) Author: Jesse Noller (jnoller) Date: 2009-06-29 13:50
+1 to this, and I'd need to make the same patch/change to 
multiprocessing.Process as well
msg95585 - (view) Author: Ask Solem (asksol) Date: 2009-11-21 15:32
Patch for multiprocessing, adding the daemon kwarg attached.
History
Date User Action Args
2009-11-21 15:32:40asksolsetfiles: + 6064-multiprocessing-daemon-kwarg.patch
nosy: + asksol
messages: + msg95585

2009-08-06 02:14:14jnollersetassignee: jnoller
2009-06-29 13:50:04jnollersetnosy: + jnoller
messages: + msg89836
2009-06-17 21:14:46pitrousetnosy: + pitrou
messages: + msg89481
2009-06-17 18:23:28ptnsetmessages: + msg89475
2009-06-17 18:12:45confsetnosy: + conf
messages: + msg89474
2009-06-17 18:12:35ptnsetmessages: + msg89473
2009-06-17 17:52:40tebekasetfiles: + threading3k.diff

messages: + msg89472
2009-06-17 17:38:35tebekasetmessages: + msg89471
2009-06-17 17:34:54ptnsetfiles: + threading.py

messages: + msg89470
2009-06-17 16:20:39tebekasetfiles: + threading.diff

messages: + msg89467
2009-06-17 15:51:14ptnsetnosy: + ptn
messages: + msg89465
2009-05-21 21:27:44tebekasetmessages: + msg88169
2009-05-20 22:52:16tebekasetfiles: + threading.diff
keywords: + patch
messages: + msg88142
2009-05-20 17:38:30amaury.forgeotdarcsetkeywords: + easy
2009-05-19 19:39:32rhettingersetversions: + Python 3.2
2009-05-19 19:39:19rhettingersetnosy: + rhettinger
messages: + msg88094
2009-05-19 19:14:00tebekacreate