I've written a working wrapper around the python multiprocessing code so I can easily start, clean up, and catch errors in my processes. I've recently decided to go back and add proper type hints to this code, however I can't figure out how to use the types defined in multiprocessing correctly.
I have a function which accepts a list of ApplyResult objects and extracts those results, before returning a list of those results (if successful)
from typing import Any
from typing import TypeVar
import multiprocessing as mp
_T = TypeVar("_T")
def wait_for_pool_results(
    results: list[mp.pool.ApplyResult[_T]],
    terminate_process_event: mp.Event,
    result_timeout: int,
) -> list[_T]:
    do_stuff()
When running this code I get the following error:
    results: list[mp.pool.ApplyResult[_T]],
AttributeError: module 'multiprocessing' has no attribute 'pool'
Looking through the code, this is the location of the ApplyResult definition, and it's not available via mp.ApplyResult either.
I could change this type hint to an Any to get around the issue (I currently do).
How do I access the ApplyResult type from python's multiprocessing library?
Furthermore, although I can assign the mp.Event type mypy complains that Mypy: Function "multiprocessing.Event" is not valid as a type. How do I correctly access this type too?
 
    