_socket.pyc
1 o 2 >��c�u � @ s� d dl Z d dlZd dlZd dlZd dlmZ d dlm Z d dl 3 Zd dlZddl mZ G dd� d�Zzd dlmZ W n eyI ejd krGd 4 ZY nw e�d�Ze�d�Zd d� Zdd� ZejejB Zd2dd�Zdd� Zdd� Zdd� Zeejddd�d3dd��Zejd ks�e s�e ed�r�eej!ddd�dd� �Z!eej"ddd�dd � �Z"eejddd�ej#ej$d dfd!d"��Zd#d$� Z%e&ed%d �e&ed&d �B Z'd'd(� Z(d4d*d+�Z)d,d-� Z*G d.d/� d/�Z+G d0d1� d1e+�Z,dS )5� N)�wraps)� TYPE_CHECKING� )�_corec @ s. e Zd Zd 5 dd�Zdd� Zdd� Zdd � ZdS )� _try_syncNc C s 6 || _ d S �N)�_blocking_exc_override)�selfZblocking_exc_override� r 7 ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\trio\_socket.py�__init__ s 8 z_try_sync.__init__c C s | j d u r 9 t|t�S | � |�S r )r � 10 isinstance�BlockingIOError)r �excr 11 r 12 r �_is_blocking_io_error s 13 14 15 z_try_sync._is_blocking_io_errorc � s �t j�� I d H d S r )�trio�lowlevel�checkpoint_if_cancelled�r r 16 r 17 r � 18 __aenter__ s �z_try_sync.__aenter__c � s, �|d ur| � |�rdS tj�� I d H dS )NTF)r r r �cancel_shielded_checkpoint)r �etype�value�tbr 19 r 20 r � __aexit__# s 21 �z_try_sync.__aexit__r )�__name__� 22 __module__�__qualname__r r r r r 23 r 24 r 25 r r s 26 27 r )�IPPROTO_IPV6�win32�) �hostname_resolver�socket_factoryc C � t �d�}t �| � |S )a\ Set a custom hostname resolver. 28 29 By default, Trio's :func:`getaddrinfo` and :func:`getnameinfo` functions 30 use the standard system resolver functions. This function allows you to 31 customize that behavior. The main intended use case is for testing, but it 32 might also be useful for using third-party resolvers like `c-ares 33 <https://c-ares.haxx.se/>`__ (though be warned that these rarely make 34 perfect drop-in replacements for the system resolver). See 35 :class:`trio.abc.HostnameResolver` for more details. 36 37 Setting a custom hostname resolver affects all future calls to 38 :func:`getaddrinfo` and :func:`getnameinfo` within the enclosing call to 39 :func:`trio.run`. All other hostname resolution in Trio is implemented in 40 terms of these functions. 41 42 Generally you should call this function just once, right at the beginning 43 of your program. 44 45 Args: 46 hostname_resolver (trio.abc.HostnameResolver or None): The new custom 47 hostname resolver, or None to restore the default behavior. 48 49 Returns: 50 The previous hostname resolver (which may be None). 51 52 N)� _resolver�get�set)r! �oldr 53 r 54 r �set_custom_hostname_resolverB s 55 56 r( c C r# )a� Set a custom socket object factory. 57 58 This function allows you to replace Trio's normal socket class with a 59 custom class. This is very useful for testing, and probably a bad idea in 60 any other circumstance. See :class:`trio.abc.HostnameResolver` for more 61 details. 62 63 Setting a custom socket factory affects all future calls to :func:`socket` 64 within the enclosing call to :func:`trio.run`. 65 66 Generally you should call this function just once, right at the beginning 67 of your program. 68 69 Args: 70 socket_factory (trio.abc.SocketFactory or None): The new custom 71 socket factory, or None to restore the default behavior. 72 73 Returns: 74 The previous socket factory (which may be None). 75 76 N)�_socket_factoryr% r&