def __init__(self, **kwargs):
        new_kwargs = get_existent_kwargs_subset(PROCESS_POOL_KWARGS_WHITELIST,
                                                kwargs)

        self.did_overwrite_start_method = False
        if kwargs.get("start_method", None) is not None:
            self.did_overwrite_start_method = True
            self.old_start_method = multiprocessing.get_start_method()
            start_method = kwargs["start_method"]
            logging.info(
                f"Overwriting start_method to {start_method}. Previous value: {self.old_start_method}"
            )
            multiprocessing.set_start_method(start_method, force=True)

        ProcessPoolExecutor.__init__(self, **new_kwargs)
Beispiel #2
0
    def __init__(self, **kwargs):
        assert (not "start_method" in kwargs
                or kwargs["start_method"] is None) or (
                    not "mp_context" in kwargs
                ), "Cannot use both `start_method` and `mp_context` kwargs."

        new_kwargs = get_existent_kwargs_subset(PROCESS_POOL_KWARGS_WHITELIST,
                                                kwargs)

        mp_context = None

        if "mp_context" in kwargs:
            mp_context = kwargs["mp_context"]
        elif "start_method" in kwargs and kwargs["start_method"] is not None:
            mp_context = multiprocessing.get_context(kwargs["start_method"])
        elif "MULTIPROCESSING_DEFAULT_START_METHOD" in os.environ:
            mp_context = multiprocessing.get_context(
                os.environ["MULTIPROCESSING_DEFAULT_START_METHOD"])
        else:
            mp_context = multiprocessing.get_context("spawn")

        new_kwargs["mp_context"] = mp_context

        ProcessPoolExecutor.__init__(self, **new_kwargs)
Beispiel #3
0
    def __init__(self, **kwargs):
        new_kwargs = get_existent_kwargs_subset(PROCESS_POOL_KWARGS_WHITELIST,
                                                kwargs)

        ProcessPoolExecutor.__init__(self, **new_kwargs)
Beispiel #4
0
 def __init__(self, max_workers=None):
     if max_top_workers:
         max_workers = int(max_top_workers)
     ProcessPoolExecutor.__init__(self, max_workers)
Beispiel #5
0
 def __init__(self, *args, **kwargs):
     self._state_manager = multiprocessing.Manager()
     ProcessPoolExecutor.__init__(self, *args, **kwargs)