Skip to content

incorrect [attribute-error] for multiprocessing.current_process()._identity[0] #1010

@nik-sm

Description

@nik-sm

This snippet works, but pytype gives [attribute-error]:

File "scrap.py", line 6, in worker_fn: No attribute '_identity' on multiprocessing.process.BaseProcess [attribute-error]

import multiprocessing
from multiprocessing import Pool


def worker_fn(x):
    worker_idx = multiprocessing.current_process()._identity[0]
    print(f"worker idx: {worker_idx}")
    return x ** 2


with Pool(4) as pool:
    results = pool.map(worker_fn, range(8))

print(results)
$ pytype --version
2021.09.09

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions