� I�g��p�dZddlmZddlmZddlmZdad�ZGd�de��ZGd �d e��Z dS) z�Utility function to construct a loky.ReusableExecutor 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. �)�get_memmapping_reducers)�TemporaryResourcesManager)�_ReusablePoolExecutorNc �&�tj|fi|��S�N)�MemmappingExecutor�get_memmapping_executor)�n_jobs�kwargss �_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/joblib/executor.pyr r s�� � 5�f� G� G�� G� G�G�c�T��eZdZe d�fd� ��Zd d�Zed���Z�xZS) r�,N�c ����|���} | �|r|ni��| �t|||�����tdup t| k} | at |��} t dd| jd�|��\} } t���|| | | ||||���\}}|s| |_ |�|j � |��|S)z_Factory for ReusableExecutor with automatic memmapping for large numpy arrays. )�timeout� initializer�initargsNT)�unlink_on_gc_collect�temp_folder_resolver)� job_reducers�result_reducers�reuserrr�envr) �copy�update�dict�_executor_argsrr�resolve_temp_folder_name�super�get_reusable_executor�_temp_folder_manager�register_new_context)�clsr rrrr� temp_folder� context_id� backend_args� executor_argsr�managerrr� _executor�executor_is_reused� __class__s �r r z*MemmappingExecutor.get_memmapping_executors6���%�)�)�+�+� ����C�/�S�S�R�0�0�0����T���x�I�I�I� J� J� J��$�&�I�.�M�*I��&��+�K�8�8�� )@�)�!%�!(�!A�)�)��)�)�%� �o�).���(E�(E� �����k��3�)F�) �) �%� �%� "� 5� .5�I� *� � !� � *� ?� ?� � K� K� K��r Fc��|�|���|j5|j�|d���ddd��dS#1swxYwYdS)N)� kill_workersT)�force�allow_non_empty)�shutdown�_submit_resize_lockr"�_clean_temporary_resources)�selfr.s r � terminatezMemmappingExecutor.terminateIs��� � � �<� �0�0�0�� %� � � � %� @� @�"�D� A� � � � � � � � � � � � � � � ���� � � � � � s�A�A �A c�|�t|dd���|jS|j���|_|jS)N�_cached_temp_folder)�getattrr7r"r)r4s r � _temp_folderzMemmappingExecutor._temp_folder[s@�� �4�.�� 5� 5� A��+� +�'+�'@�'Y�'Y�'[�'[�D� $��+� +r )rNrNNN)F) �__name__� __module__� __qualname__� classmethodr r5�propertyr9� __classcell__�r,s@r rrs���������FJ�CG�+/�-�-�-�-�-��[�-�^����$� ,� ,��X� ,� ,� ,� ,� ,r rc�(��eZdZdZd�Z�fd�Z�xZS)�_TestingMemmappingExecutorzWrapper around ReusableExecutor to ease memmapping testing with Pool and Executor. This is only for testing purposes. c�:�|j|g|�R�}|j|_|S)zSchedule a func to be run)�submit�result�get)r4�func�args�futures r � apply_asyncz&_TestingMemmappingExecutor.apply_asyncns)�����T�)�D�)�)�)���]�� �� r c�R��tt��j|g|�R���Sr)�listr �map)r4�frHr,s �r rMz_TestingMemmappingExecutor.mapts)����K�E�G�G�K��)�D�)�)�)�*�*�*r )r:r;r<�__doc__rJrMr?r@s@r rBrBisQ������������ +�+�+�+�+�+�+�+�+r rB) rO�_memmapping_reducerrr� externals.loky.reusable_executorrrr rrBrr r �<module>rRs�����9�8�8�8�8�8�:�:�:�:�:�:�C�C�C�C�C�C���H�H�H�O,�O,�O,�O,�O,�.�O,�O,�O,�d +� +� +� +� +�!3� +� +� +� +� +r
Memory