Skip to content

Objects on running thread are not deleted #139542

@efimov-mikhail

Description

@efimov-mikhail

Bug report

Bug description:

import time, _thread

class F:
    def __del__(self):
        print("del")

def waitingThread():
    lock.release()
    f = F()
    time.sleep(10)

lock = _thread.allocate_lock()
lock.acquire()
_thread.start_new_thread(waitingThread, ())
lock.acquire()

I anticipate "del" text to be printed.
But it seems that f is not decrefed to zero, and __del__ method is not called.

FWIW, this code snippet is a variant of test.test_threading.ThreadTests.test_finalize_running_thread.

CPython versions tested on:

CPython main branch, 3.11.2

Operating systems tested on:

linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions