Visitar URL original
intermittent ResourceTracker called reentrantly for resource cleanup in tests · Issue #131788 · python/cpython · GitHub
Skip to content

intermittent ResourceTracker called reentrantly for resource cleanup in tests #131788

Closed

Description

@graingert

Bug report

Bug description:

I occasionally see

UserWarning: ResourceTracker called reentrantly for resource cleanup, which is unsupported. The semaphore object '/mp-gtkzf9rd' might leak.

warned in the test logs, I suspect test_force_shutdown_workers_dead_workers is the culprit.

It looks like the ResourceTracker was built to warn on re-entrant execution but I think it can be made to work instead.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added a commit that references this issue on Aug 13, 2025
  2. added 2 commits that reference this issue on Aug 13, 2025
  3. added a commit that references this issue on Aug 14, 2025
  4. added a commit that references this issue on Aug 19, 2025
  5. gpshead commented on Aug 20, 2025

    @gpshead
    Member

    heads up that backports seem to have happened and the PR shipped in 3.13.7 and at least one person says it is causing unspecified as of yet issues cc: @ngoldbaum - #137738 (comment)

    my own comment on the PR many moons ago when approving did question if this was safe enough to backport, but the automation was still in place so those understandably happened regardless (it has not landed in 3.14 yet due to rc phase). #131787 (comment)

  6. ngoldbaum commented on Aug 20, 2025

    @ngoldbaum
    Contributor

    It looks like the backport of the fix for this issue is causing problems in the loky project, which is used by joblib (in turn used by lots of stuff, including scikit-learn).

    joblib/loky#459

    joblib/joblib#1738

  7. geofft commented on Aug 21, 2025

    @geofft
    Contributor

    I think we have another couple of reports of this regression over at astral-sh/python-build-standalone#774. Specifically note that all the reports are that this is failing on Windows with an ImportError for _posixsubprocess, which is imported by multiprocessing.util.spawnv_passfds(), the call to which moved around in this PR.

    Did something on this PR cause code to run on Windows that was previously getting skipped (or ImportError to be swallowed)?

  8. zanieb commented on Aug 21, 2025

    @zanieb
    Contributor

    @geofft fyi I opened #138031 for that specific error since @ngoldbaum's report also includes ValueError: Cannot register X for automatic cleanup: unknown resource type Y.

  9. added a commit that references this issue on Aug 28, 2025
  10. ngoldbaum commented on Oct 16, 2025

    @ngoldbaum
    Contributor

    It looks like this got reverted in 3.13 - is there any appetite to also revert it for 3.14? It looks like the mypy tests also hit this under 3.14t.

    EDIT: never mind, I'm seeing the errors that were fixed by this PR. So what I'd need is for this PR to be applied to the 3.14 branch, which would probably then break uv.

  11. ngoldbaum commented on Oct 16, 2025

    @ngoldbaum
    Contributor
  12. zanieb commented on Oct 16, 2025

    @zanieb
    Contributor

    I posted a revert at #138222 but it never merged, instead loky fixed the issue on their end and that was considered sufficient for closing #138031.

    #137737 was put on hold due to the loky regression, but I think we can merge that now — the outstanding questions have been resolved (cc @gpshead).

    So what I'd need is for this PR to be applied to the 3.14 branch, which would probably then break uv.

    This won't break uv, to my knowledge. We just got reports of the loky issue when people upgraded to the latest version of 3.13.

  13. ngoldbaum commented on Oct 16, 2025

    @ngoldbaum
    Contributor

    Thanks for explaining, so I guess the fix is to merge #137737.

  14. ngoldbaum commented on Oct 16, 2025

    @ngoldbaum
    Contributor

    ping @hugovk as 3.14 release manager

  15. self-assigned this
    on Oct 17, 2025
  16. gpshead commented on Oct 17, 2025

    @gpshead
    Member

    I synced the 3.14 PR and kicked off extra tests. re-ping me on that tomorrow it hasn't been merged already.

  17. added a commit that references this issue on Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions