Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "daemon" argument to threading.Thread constructor #50314

Closed
tebeka mannequin opened this issue May 19, 2009 · 21 comments
Closed

Add "daemon" argument to threading.Thread constructor #50314

tebeka mannequin opened this issue May 19, 2009 · 21 comments
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@tebeka
Copy link
Mannequin

tebeka mannequin commented May 19, 2009

BPO 6064
Nosy @rhettinger, @tebeka, @pitrou
Files
  • threading.diff: Patch
  • threading.diff: Diff againt r73465
  • threading.py
  • threading3k.diff: Diff
  • 6064-multiprocessing-daemon-kwarg.patch: Patch for multiprocessing
  • threading3k.diff: patch for threading
  • multiprocessing3k.diff: patch for multiprocessing
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2011-02-25.22:08:28.985>
    created_at = <Date 2009-05-19.19:14:00.577>
    labels = ['easy', 'type-feature', 'library']
    title = 'Add "daemon" argument to threading.Thread constructor'
    updated_at = <Date 2011-02-25.22:51:15.316>
    user = 'https://github.com/tebeka'

    bugs.python.org fields:

    activity = <Date 2011-02-25.22:51:15.316>
    actor = 'tebeka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-02-25.22:08:28.985>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2009-05-19.19:14:00.577>
    creator = 'tebeka'
    dependencies = []
    files = ['14029', '14312', '14313', '14314', '15376', '18152', '18153']
    hgrepos = []
    issue_num = 6064
    keywords = ['patch', 'easy']
    message_count = 21.0
    messages = ['88088', '88094', '88142', '88169', '89465', '89467', '89470', '89471', '89472', '89473', '89474', '89475', '89481', '89836', '95585', '111343', '111344', '111346', '111347', '129443', '129451']
    nosy_count = 9.0
    nosy_names = ['rhettinger', 'tebeka', 'pitrou', 'jnoller', 'ptn', 'conf', 'asksol', 'bbrazil', 'steven']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue6064'
    versions = ['Python 3.3']

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented May 19, 2009

    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()

    @tebeka tebeka mannequin added type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels May 19, 2009
    @rhettinger
    Copy link
    Contributor

    +1

    @amauryfa amauryfa added the easy label May 20, 2009
    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented May 20, 2009

    Attaching a patch against trunk (at revision 72805).

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented May 21, 2009

    I think that
    self.__daemonic = daemon or self._set_daemon()
    is wrong, need to thing about it.

    @ptn
    Copy link
    Mannequin

    ptn mannequin commented Jun 17, 2009

    +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).

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Jun 17, 2009

    I'm attaching a new diff (svn diff > threading.diff), hope this one's OK.

    @ptn
    Copy link
    Mannequin

    ptn mannequin commented Jun 17, 2009

    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.

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Jun 17, 2009

    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.

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Jun 17, 2009

    Attaching a diff against the py3k branch on revision 73468

    @ptn
    Copy link
    Mannequin

    ptn mannequin commented Jun 17, 2009

    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 :)

    @conf
    Copy link
    Mannequin

    conf mannequin commented Jun 17, 2009

    +1 to the py3k diff. :)
    Hey, I think this daemon property should be set as a keyword argument of
    the Thread constructor.

    @ptn
    Copy link
    Mannequin

    ptn mannequin commented Jun 17, 2009

    +1 on making it a keyword-only argument.

    @pitrou
    Copy link
    Member

    pitrou commented Jun 17, 2009

    +1 from me as well.

    @jnoller
    Copy link
    Mannequin

    jnoller mannequin commented Jun 29, 2009

    +1 to this, and I'd need to make the same patch/change to
    multiprocessing.Process as well

    @jnoller jnoller mannequin self-assigned this Aug 6, 2009
    @asksol
    Copy link
    Mannequin

    asksol mannequin commented Nov 21, 2009

    Patch for multiprocessing, adding the daemon kwarg attached.

    @steven
    Copy link
    Mannequin

    steven mannequin commented Jul 23, 2010

    Hello, I've taken the liberty of updating the two patch files here for python3.2 at revision 83065. Apologies if I'm treading on anyones toes here. I'm taking part in a europython sprint and this is the first time I've tried this.

    I've modified the multiprocessing patch. The documentation didn't agree with the behaviour of the code, so I've changed the Doc file. I've also added an extra test for the default behaviour.

    I've reviewed the code for PEP-8 (as an exercise for me) and run the tests and they passed ok.

    Steven

    @steven steven mannequin added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jul 23, 2010
    @steven
    Copy link
    Mannequin

    steven mannequin commented Jul 23, 2010

    Here's the patch for multiprocessing based on python 3 revision 83065, all credit to the original author, all problems probably mine!
    Steven

    @bbrazil
    Copy link
    Mannequin

    bbrazil mannequin commented Jul 23, 2010

    I've updated the patch for 3.2 and improved the documentation formatting.

    @bbrazil
    Copy link
    Mannequin

    bbrazil mannequin commented Jul 23, 2010

    Looks like it lost my patch, but Steven's does the same.

    One tweak: in threading.rst put all of the class signature on one line or the html formatting will be a bit off.

    @pitrou pitrou added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jan 6, 2011
    @pitrou
    Copy link
    Member

    pitrou commented Feb 25, 2011

    I corrected the patches (they were breaking the property of inheriting daemon by default) and committed them in r88618. Thank you!

    @pitrou pitrou closed this as completed Feb 25, 2011
    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Feb 25, 2011

    Thank you!

    On Fri, Feb 25, 2011 at 2:08 PM, Antoine Pitrou <report@bugs.python.org> wrote:

    Antoine Pitrou <pitrou@free.fr> added the comment:

    I corrected the patches (they were breaking the property of inheriting daemon by default) and committed them in r88618. Thank you!

    ----------
    resolution:  -> fixed
    stage: patch review -> committed/rejected
    status: open -> closed


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue6064\>


    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants