� ���gt��l�ddlZddlZddlZ ddlZn #e$rdZYnwxYwddlmZGd�de��ZdS)�N�)� PubSubManagerc�^��eZdZdZdZ d�fd� Z�fd�Zd �Zd �Zd �Z d �Z d �Z d�Z �xZ S)� KombuManageraClient manager that uses kombu for inter-process messaging. This class implements a client manager backend for event sharing across multiple processes, using RabbitMQ, Redis or any other messaging mechanism supported by `kombu <http://kombu.readthedocs.org/en/latest/>`_. To use a kombu backend, initialize the :class:`Server` instance as follows:: url = 'amqp://user:password@hostname:port//' server = socketio.Server(client_manager=socketio.KombuManager(url)) :param url: The connection URL for the backend messaging queue. Example connection URLs are ``'amqp://guest:guest@localhost:5672//'`` and ``'redis://localhost:6379/'`` for RabbitMQ and Redis respectively. Consult the `kombu documentation <http://kombu.readthedocs.org/en/latest/userguide /connections.html#urls>`_ for more on how to construct connection URLs. :param channel: The channel name on which the server sends and receives notifications. Must be the same in all the servers. :param write_only: If set to ``True``, only initialize to emit events. The default of ``False`` initializes the class for emitting and receiving. :param connection_options: additional keyword arguments to be passed to ``kombu.Connection()``. :param exchange_options: additional keyword arguments to be passed to ``kombu.Exchange()``. :param queue_options: additional keyword arguments to be passed to ``kombu.Queue()``. :param producer_options: additional keyword arguments to be passed to ``kombu.Producer()``. �kombu�#amqp://guest:guest@localhost:5672//�socketioFNc ���t�td���t���|||���||_|pi|_|pi|_|pi|_|pi|_|� ��|_ dS)NzLKombu package is not installed (Run "pip install kombu" in your virtualenv).)�channel� write_only�logger) r� RuntimeError�super�__init__�url�connection_options�exchange_options� queue_options�producer_options� _connection�publisher_connection) �selfrr r r rrrr� __class__s ��f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/kombu_manager.pyrzKombuManager.__init__1s���� �=�� .�/�/� /� ������Z���O�O�O����"4�":���� 0� 6�B���*�0�b��� 0� 6�B���$(�$4�$4�$6�$6��!�!�!�c� ��t�����d}|jjdkrddlm}|d��}nd|jjvrddlm}|d��}|std|jjz���dS) NT�eventletr)�is_monkey_patched�socket�gevent)�is_module_patchedz<Kombu requires a monkey patched socket library to work with ) r� initialize�server� async_mode�eventlet.patcherr� gevent.monkeyr!r)r�monkey_patchedrr!rs �rr"zKombuManager.initializeAs���� ���������� �;� !�Z� /� /� :� :� :� :� :� :�.�.�x�8�8�N�N� ���/� /� /� 7� 7� 7� 7� 7� 7�.�.�x�8�8�N�� 2����+�0�1�2�2� 2� 2� 2rc�:�tj|jfi|j��S)N)r� Connectionrr)rs rrzKombuManager._connectionPs ������D�D�D�,C�D�D�Drc�n�ddd�}|�|j��tj|jfi|��S)N�fanoutF)�type�durable)�updaterr�Exchanger )r�optionss r� _exchangezKombuManager._exchangeSs>��#��6�6�����t�,�-�-�-��~�d�l�6�6�g�6�6�6rc���dttj����z}dddid�}|�|j��t j||���fi|��S)Nzpython-socketio.Fz x-expiresi��)r-�queue_arguments)�str�uuid�uuid4r.rr�Queuer1)r� queue_namer0s r�_queuezKombuManager._queueXse��'�#�d�j�l�l�*;�*;�;� �#��f�8M�N�N�����t�)�*�*�*��{�:�t�~�~�'7�'7�C�C�7�C�C�Crc��|jdd|���i|j��}|�||j��S)N�exchange�)�Producerr1r�ensure�publish)r� connection�producers r�_producer_publishzKombuManager._producer_publish^sU��&�:�&�@�@����0@�0@�@�)-�)>�@�@��� � ��8�+;�<�<�<rc�l�d} |�|j��}|tj|����dS#tt jjf$rY|r*|���� d��d}n*|���� d��YdSYnwxYw��)NTz&Cannot publish to rabbitmq... retryingFz'Cannot publish to rabbitmq... giving up) rBr�pickle�dumps�OSErrorr� exceptions� KombuError� _get_logger�error)r�data�retry�producer_publishs r�_publishzKombuManager._publishcs����� � �#'�#9�#9��-�$/�$/� � � ���d�!3�!3�4�4�4�����U�-�8�9� � � ����$�$�&�&�,�,�.8�9�9�9�!�E�E��$�$�&�&�,�,�A�C�C�C��E�E� �E�  ����  s�7>�A.B2�1B2c#�JK�|���}d} |���5}|�|��5} |�d���}|���|jV�d}�6#1swxYwY ddd��n #1swxYwYn�#t tjj f$rd|� ��� d� |����tj|��t|dzd��}YnwxYw�� )NrT)�blockz3Cannot receive from rabbitmq... retrying in {} secs��<)r9r� SimpleQueue�get�ack�payloadrFrrGrHrIrJ�format�time�sleep�min)r� reader_queue� retry_sleepr@�queue�messages r�_listenzKombuManager._listenus������{�{�}�}� �� � 7� 7��%�%�'�'�,�:�#�/�/� �=�=�,��,�&+�i�i�d�i�&;�&;�G�#�K�K�M�M�M�")�/�1�1�1�*+�K� ,�,�,�,�,����,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,����U�-�8�9� 7� 7� 7�� � �"�"�(�(�*�*0�&��*=�*=�?�?�?�� �;�'�'�'�!�+��/�2�6�6� � � �  7���� 7sS�B!�B�8A=�=B �B�B �B� B!�B�B!�B�B!�!A<D �D )rr FNNNNN)�__name__� __module__� __qualname__�__doc__�namerr"rr1r9rBrNr_� __classcell__)rs@rrr s�������� � �B �D�@�>B�;?�6:�7�7�7�7�7�7� 2� 2� 2� 2� 2�E�E�E�7�7�7� D�D�D� =�=�=� ���$7�7�7�7�7�7�7rr)rDrXr5r� ImportError�pubsub_managerrrr<rr�<module>rhs��� � � � � � � � � � � � ���L�L�L�L������ �E�E�E�����*�)�)�)�)�)�y7�y7�y7�y7�y7�=�y7�y7�y7�y7�y7s ���
Memory