o
�J�h^p � @ s6 d Z ddlZddlZddlZddlZddlZddlmZmZ ddl m
Z
ddlmZm
Z
e
durPddlmZ ddlmZ dd lmZmZ dd
lmZ ddlmZ G dd
� d
ed�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� dee�ZG dd� deee�ZG dd� dee�Z G dd� de!�Z"dd� Z#dS )z,
Backends for embarrassingly parallel code.
� N)�ABCMeta�abstractmethod� )�mp)�*_retrieve_traceback_capturing_wrapped_call�_TracebackCapturingWrapper)�
ThreadPool)�get_memmapping_executor)� cpu_count�process_executor)�ShutdownExecutorError)�MemmappingPoolc s� e Zd ZdZdZdZdZedd� �Zedd� �Z dZ
d.� fd d
� Zg d�ZdZ
ed
d� �Zd/dd�Zd/dd�Zdd� Zd/dd�Z d0dd�Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd1d$d%�Zd&d'� Zd(d)� Zejd*d+� �Ze d,d-� �Z!� Z"S )2�ParallelBackendBasezEHelper abc which defines all methods a ParallelBackend must implementr Fc C � | j S �N��supports_retrieve_callback��self� r �WC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\joblib\_parallel_backends.py�supports_return_generator) � z-ParallelBackendBase.supports_return_generatorc C r r r r r r r �supports_timeout- r z$ParallelBackendBase.supports_timeoutNc s t � �� || _|| _|| _d S r )�super�__init__�
nesting_level�inner_max_num_threads�backend_kwargs)r r r r �� __class__r r r 3 s
zParallelBackendBase.__init__)ZOMP_NUM_THREADSZOPENBLAS_NUM_THREADSZMKL_NUM_THREADSZBLIS_NUM_THREADSZVECLIB_MAXIMUM_THREADS�NUMBA_NUM_THREADSZNUMEXPR_NUM_THREADSZ
ENABLE_IPCc C � dS )a� Determine the number of jobs that can actually run in parallel
n_jobs is the number of workers requested by the callers. Passing
n_jobs=-1 means requesting all available workers for instance matching
the number of CPU cores on the worker host(s).
This method should return a guesstimate of the number of workers that
can actually perform work concurrently. The primary use case is to make
it possible for the caller to know in how many chunks to slice the
work.
In general working on larger data chunks is more efficient (less
scheduling overhead and better use of CPU cache prefetching heuristics)
as long as all the workers have enough work to do.
Nr �r �n_jobsr r r �effective_n_jobsG � z$ParallelBackendBase.effective_n_jobsc C � t d��)z'Deprecated: implement `submit` instead.zImplement `submit` instead.)�NotImplementedError�r �func�callbackr r r �apply_asyncY � zParallelBackendBase.apply_asyncc C s t �dt� | �||�S )a8 Schedule a function to be run and return a future-like object.
This method should return a future-like object that allow tracking
the progress of the task.
If ``supports_retrieve_callback`` is False, the return value of this
method is passed to ``retrieve_result`` instead of calling
``retrieve_result_callback``.
Parameters
----------
func: callable
The function to be run in parallel.
callback: callable
A callable that will be called when the task is completed. This callable
is a wrapper around ``retrieve_result_callback``. This should be added
to the future-like object returned by this method, so that the callback
is called when the task is completed.
For future-like backends, this can be achieved with something like
``future.add_done_callback(callback)``.
Returns
-------
future: future-like
A future-like object to track the execution of the submitted function.
z@`apply_async` is deprecated, implement and use `submit` instead.)�warnings�warn�DeprecationWarningr, r) r r r �submit] s
�zParallelBackendBase.submitc C r"