o
    h                     @   s^   d dl Z d dlZd dlZd dlmZ G dd dZG dd dejjZG dd dejj	Z	dS )	    N)ForkingPicklerc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )ConnectionWrapperz_Proxy class for _multiprocessing.Connection which uses ForkingPickler for object serialization.c                 C   s
   || _ d S N)conn)selfr    r   o/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/multiprocessing/queue.py__init__   s   
zConnectionWrapper.__init__c                 C   s,   t  }t|tj| | |  d S r   )ioBytesIOr   pickleHIGHEST_PROTOCOLdump
send_bytesgetvalue)r   objbufr   r   r   send   s   zConnectionWrapper.sendc                 C   s   |   }t|S r   )
recv_bytesr   loads)r   r   r   r   r   recv   s   
zConnectionWrapper.recvc                 C   s,   d| j v rt| j|S tdt| j d)Nr   'z ' object has no attribute 'conn')__dict__getattrr   AttributeErrortype__name__)r   namer   r   r   __getattr__   s   
zConnectionWrapper.__getattr__N)r   
__module____qualname____doc__r	   r   r   r   r   r   r   r   r      s    r   c                          e Zd Z fddZ  ZS )Queuec                    sB   t  j|i | t| j| _t| j| _| jj| _| jj| _d S r   )	superr	   r   _reader_writerr   _sendr   _recv)r   argskwargs	__class__r   r   r	      s
   
zQueue.__init__)r   r   r    r	   __classcell__r   r   r+   r   r#          r#   c                       r"   )SimpleQueuec                    s2   t | jtst| j| _t| j| _t   d S r   )
isinstancer%   r   r&   r$   _make_methods)r   r+   r   r   r1   '   s   zSimpleQueue._make_methods)r   r   r    r1   r-   r   r   r+   r   r/   &   r.   r/   )
r
   multiprocessing.queuesmultiprocessingr   multiprocessing.reductionr   r   queuesr#   r/   r   r   r   r   <module>   s   	