a
    xd                     @   sp   d dl Z d dlmZ d dlZd dlmZmZ zd dlmZ dZW n e	yV   dZY n0 edd Z
d	d
 ZdS )    N)contextmanager)socketSOCK_STREAM)AF_UNIXTFc                 c   s&   z
| V  W n   |     Y n0 d S )N)close)obj r   X/var/www/html/Ranjet/env/lib/python3.9/site-packages/trio/_highlevel_open_unix_stream.pyclose_on_error   s
    
r
   c                    s^   t stdttt}t|& |t| I dH  W d   n1 sJ0    Y  t	
|S )a  Opens a connection to the specified
    `Unix domain socket <https://en.wikipedia.org/wiki/Unix_domain_socket>`__.

    You must have read/write permission on the specified file to connect.

    Args:
      filename (str or bytes): The filename to open the connection to.

    Returns:
      SocketStream: a :class:`~trio.abc.Stream` connected to the given file.

    Raises:
      OSError: If the socket file could not be connected to.
      RuntimeError: If AF_UNIX sockets are not supported.
    z/Unix sockets are not supported on this platformN)has_unixRuntimeErrorr   r   r   r
   connectosfspathtrioZSocketStream)filenamesockr   r   r	   open_unix_socket   s    

4r   )r   
contextlibr   r   Ztrio.socketr   r   r   r   ImportErrorr
   r   r   r   r   r	   <module>   s   

