�
I�gO8 � �P � d Z ddlZddlZddlZddlmZ e n# e$ r ed� � ZY nw xY wddl m
Z
ddl mZ ddlm
Z
ddlmZ dd lmZ dd
lmZmZ ddlmZ ddlZn
# e$ r dZY nw xY w G d� d
e
� � Z G d� de� � Z G d� de� � Z G d� de� � ZdS )a� Custom implementation of multiprocessing.Pool with custom pickler.
This module provides efficient ways of working with data stored in
shared memory with numpy.memmap arrays without inducing any memory
copy between the parent and child processes.
This module should not be imported if multiprocessing is not
available as it implements subclasses of multiprocessing Pool
that uses a custom alternative to SimpleQueue.
� N)�sleep)�Pickler)�HIGHEST_PROTOCOL)�BytesIO� )�get_memmapping_reducers)�TemporaryResourcesManager)�mp�assert_spawning)�Poolc �$ � e Zd ZdZdefd�Zd� ZdS )�CustomizablePicklera� Pickler that accepts custom reducers.
TODO python2_drop : can this be simplified ?
HIGHEST_PROTOCOL is selected by default as this pickler is used
to pickle ephemeral datastructures for interprocess communication
hence no backward compatibility is required.
`reducers` is expected to be a dictionary with key/values
being `(type, callable)` pairs where `callable` is a function that
give an instance of `type` will return a tuple `(constructor,
tuple_of_objects)` to rebuild an instance out of the pickled
`tuple_of_objects` as would return a `__reduce__` method. See the
standard library documentation on pickling for more details.
Nc �T � t j | ||�� � |�i }t t d� � r$t j � � � | _ n#t
j � � � | _ |� � � D ]\ }}| � ||� � �d S )N)�protocol�dispatch) r �__init__�hasattrr �copy�copyreg�dispatch_table�items�register)�self�writer�reducersr �type�reduce_funcs �[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/joblib/pool.pyr zCustomizablePickler.__init__H s� � ����v��9�9�9�9����H��7�J�'�'� @� $�,�1�1�3�3�D�M�M� #*�"8�"=�"=�"?�"?�D��!)���!1�!1� -� -��D�+��M�M�$��,�,�,�,� -� -� c �h �� t t d� � r�fd�}|| j |<