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

thread reaping is imperfect #51471

Closed
pitrou opened this issue Oct 27, 2009 · 5 comments
Closed

thread reaping is imperfect #51471

pitrou opened this issue Oct 27, 2009 · 5 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Oct 27, 2009

BPO 7222
Nosy @pitrou, @bitdancer
Files
  • threading_setup.patch
  • threading_setup2.patch
  • 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 2009-10-30.17:25:52.452>
    created_at = <Date 2009-10-27.21:24:22.709>
    labels = ['type-bug', 'tests']
    title = 'thread reaping is imperfect'
    updated_at = <Date 2009-10-30.17:25:52.450>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2009-10-30.17:25:52.450>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-10-30.17:25:52.452>
    closer = 'pitrou'
    components = ['Tests']
    creation = <Date 2009-10-27.21:24:22.709>
    creator = 'pitrou'
    dependencies = []
    files = ['15215', '15217']
    hgrepos = []
    issue_num = 7222
    keywords = ['patch']
    message_count = 5.0
    messages = ['94582', '94584', '94586', '94592', '94716']
    nosy_count = 3.0
    nosy_names = ['nnorwitz', 'pitrou', 'r.david.murray']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7222'
    versions = ['Python 2.7', 'Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 27, 2009

    Thread reaping in test_support is imperfect because, even when a thread
    has a disappeared from _active and _limbo, the Thread object might still
    be hanging somewhere in memory (leaving its last instants). This problem
    manifests itself when trying to fix the transient refleaks in
    test_socketserver.

    One solution I've found is to add a _count() method to the thread
    module, which returns the number of running threads from the point of
    view of the C extension. When _count() is decremented, we can be sure
    the Python method has finished running and the Thread object is not
    hanging around.

    @pitrou pitrou added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Oct 27, 2009
    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 27, 2009

    Thinking about it, another possibility is to strengthen Thread.join(),
    so that it waits for the actual end of the thread, not a small instant
    before.

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 27, 2009

    Forget the last message. While improving Thread.join() can be good, it
    still doesn't guarantee that all references have been released.

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 27, 2009

    Here's a new patch with tests.

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 30, 2009

    Committed in r75958, r75959.

    @pitrou pitrou closed this as completed Oct 30, 2009
    @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
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant