← Back
Editing: garbage.cpython-311.pyc
� mc�c� � � � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z mZ ddlZ edddg� � Z G d � d e� � Z G d� d� � Z e� � ZdS ) zcGarbage collection thread for representing zmq refcount of Python objects used in zero-copy sends. � N)� namedtuple)�getpid)�Event�Lock�Thread�gcref�obj�eventc �( � � e Zd ZdZ� fd�Zd� Z� xZS )�GarbageCollectorThreadz4Thread in which garbage collection actually happens.c � �� t � � � � � || _ d| _ t � � | _ t � � | _ d S )NT)�super�__init__�gc�daemonr �pidr �ready)�selfr � __class__s ��3/usr/lib/python3/dist-packages/zmq/utils/garbage.pyr zGarbageCollectorThread.__init__ sA �� � ���������������8�8����W�W�� � � � c � � t �t � � | j k r| j � � � d S | j j � t j � � }d|_ |� | j j � � | j � � � n# | j � � � w xY w t �t � � | j k rd S |� � � }|dk rnvt |� � dk rdnd}t j ||� � d }| j j � |d � � }|r |j r|j � � � ~��|� � � d S )Nr T� DIE� �L�Q)r r r �setr �context�socket�zmq�PULL�linger�bind�url�recv�len�struct�unpack�refs�popr �close)r �s�msg�fmt�key�tups r �runzGarbageCollectorThread.run sO � ��>�V�X�X���1�1��J�N�N�����F� ����&�&�s�x�0�0�A��A�H� �F�F�4�7�;�����J�N�N������D�J�N�N�������� ��~����T�X�!5�!5����&�&�(�(�C��f�}�}���S���Q���#�#�C�C��-��S�)�)�!�,�C��'�,�"�"�3��-�-�C�� �s�y� �� � � ����� � ��� � � � � s �AB$ �$B?)�__name__� __module__�__qualname__�__doc__r r1 � __classcell__�r s @r r r sM �� � � � � �>�>�� � � � �� � � � � � r r c � � � e Zd ZdZdZdZdZdZd� fd� Ze d� � � Z e j d� � � Z d� Zd� Z d � Zd � Ze d� � � Zd� Zd � Zdd�Zd� Z� xZS )�GarbageCollectoraF PyZMQ Garbage Collector Used for representing the reference held by libzmq during zero-copy sends. This object holds a dictionary, keyed by Python id, of the Python objects whose memory are currently in use by zeromq. When zeromq is done with the memory, it sends a message on an inproc PUSH socket containing the packed size_t (32 or 64-bit unsigned int), which is the key in the dict. When the PULL socket in the gc thread receives that message, the reference is popped from the dict, and any tracker events that should be signaled fire. Nzinproc://pyzmq.gc.01c � �� t � � � � � i | _ d | _ d | _ || _ t � � | _ d| _ d | _ d | _ t j | j � � d S )NF)r r r) r �thread�_contextr �_lock� _stay_down�_push�_push_mutex�atexit�register�_atexit)r r r s �r r zGarbageCollector.__init__O sn �� � ���������� ��������� ��V�V�� ������ ��������%�%�%�%�%r c �� � | j �Wt j � d� � r ddlm} |� � � | _ nt j � � | _ | j S )N�geventr )�green)r<