Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Missing stub for multiprocessing.get_context() #1422

Closed
@khyox

Description

@khyox

Following suggestion in mypy #3564.

Repro:

import multiprocessing
import os

METHODS = ['spawn', 'fork', 'forkserver']

if __name__ == '__main__':
    for method in METHODS:
        context = multiprocessing.get_context(method)
        with context.Pool(processes=4) as pool:
            results = [pool.apply_async(os.getpid, ()) for i in range(4)]
            print([res.get(timeout=1) for res in results], method)

mypy with --check-untyped-defs or with --disallow-untyped-defs complains with the single message ...:8:18:error: Module has no attribute "get_context".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions