GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — multiprocessing.Pool: leak of global named resources using multiprocessing spawn · Issue #122770 · python/cpython

multiprocessing.Pool: leak of global named resources using multiprocessing spawn #122770

New issue
Copy link
New issue
Copy link
Open
Open
multiprocessing.Pool: leak of global named resources using multiprocessing spawn#122770
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vindex10
vindex10
opened on Aug 7, 2024
Issue body actions

Bug report

Bug description:

I'm receiving a warning when using the multiprocessing.Pool in spawn mode.

/opt/pyenv/versions/3.12.4/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

A similar issue was brought up and fixed before, when multiprocessing.Process was used:
#30617

The test case introduced by the PR above: https://github.com/python/cpython/blob/3.12/Lib/test/_test_multiprocessing.py#L6040C7-L6040C24

To trigger the warning, I just replaced the Process with Pool as follows:

import multiprocessing as mp
ctx = mp.get_context('spawn')
global_resource = ctx.Semaphore()
def submain(): pass
if __name__ == '__main__':
    p = ctx.Pool(processes=3).starmap(submain, [tuple() for i in range(5)])

CPython versions tested on:

3.11, 3.12, CPython main branch

Operating systems tested on:

Linux

Reacted by Rinat Nazarov and Joshua

Activity

  1. vindex10
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Aug 7, 2024
  2. hanke-it-nrw commented on Dec 17, 2024

    @hanke-it-nrw
    hanke-it-nrw
    on Dec 17, 2024
    More actions

    I have the same issue with context forkserver:

    import multiprocessing as mp
    from multiprocessing import Queue
    ctx = mp.get_context('forkserver')
    global_resource = ctx.Semaphore()
    def submain(): pass
    if __name__ == '__main__':
        p = ctx.Pool(processes=3).starmap(submain, [tuple() for i in range(5)])
    

    Only the number of leaked objects differ

    /usr/lib64/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 3 leaked semaphore objects to clean up at shutdown
      warnings.warn('resource_tracker: There appear to be %d '
    

    CPython versions tested on:

    3.11, 3.12, CPython main branch

    Operating systems tested on:

    Linux

  3. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-multiprocessing
    on Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.