Skip to content

How to cleanly end processes in a Pool? #419

Description

@nedbat

Coverage.py needs subprocesses to end cleanly so that all the measured data will be written out. With multiprocessing, this works to make the workers end correctly:

def test_foo():
    with multiprocessing.Pool(processes=1) as pool:
        # ... use the pool, for example: pool.apply(complex_math_verification)
        pool.close()
        pool.join()

Similar code with billiard does not end the processes cleanly:

from billiard.pool import Pool

def test_foo():
    with Pool(processes=1) as pool:
        pool.apply(complex_math_verification)
        pool.close()
        pool.join()

Coverage issues coveragepy/coveragepy#1673 and coveragepy/coveragepy#1910 have more details.

Is this a bug in billiard, or does it need different code to cleanly end the worker processes?

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions