AlkantarClanX12

Your IP : 13.59.234.182


Current Path : /proc/self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python311/lib64/python3.11/__pycache__/asyncore.cpython-311.pyc

�

c��fVO����dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZdZejeed���eee
eeeeh��Z	en
#e$riZYnwxYwd�ZGd�d	e��Zeee fZ!d
�Z"d�Z#d�Z$d
�Z%dd�Z&dd�Z'e'Z(d d�Z)Gd�d��Z*Gd�de*��Z+d�Z,d!d�Z-ej.dkrGd�d��Z/Gd�de*��Z0dSdS)"a�Basic infrastructure for asynchronous socket service clients and servers.

There are only two ways to have a program on a single processor do "more
than one thing at a time".  Multi-threaded programming is the simplest and
most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however.

If your operating system supports the select() system call in its I/O
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking
place in the "background."  Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap.
�N)
�EALREADY�EINPROGRESS�EWOULDBLOCK�
ECONNRESET�EINVAL�ENOTCONN�	ESHUTDOWN�EISCONN�EBADF�ECONNABORTED�EPIPE�EAGAIN�	errorcodeznThe {name} module is deprecated and will be removed in Python {remove}. The recommended replacement is asyncio)��)�removec��	tj|��S#tttf$r |t
vrt
|cYSd|zcYSwxYw)NzUnknown error %s)�os�strerror�
ValueError�
OverflowError�	NameErrorr)�errs �//opt/alt/python311/lib64/python3.11/asyncore.py�	_strerrorrIse��'��{�3������
�y�1�'�'�'��)����S�>�!�!�!�!�3�&�&�&�&�'���s��-A
�A
�A
c��eZdZdS)�ExitNowN)�__name__�
__module__�__qualname__��rrrQs�������Dr"rc�|�	|���dS#t$r�|���YdSxYw�N)�handle_read_event�_reraised_exceptions�handle_error��objs r�readr*V�X����������������
���������������� ;c�|�	|���dS#t$r�|���YdSxYwr$)�handle_write_eventr&r'r(s r�writer/^sX������ � � � � ������
�������������r,c�|�	|���dS#t$r�|���YdSxYwr$)�handle_expt_eventr&r'r(s r�
_exceptionr2fr+r,c�D�	|tjzr|���|tjzr|���|tjzr|���|tjtjztj	zzr|�
��dSdS#t$rH}|jtvr|���n|�
��Yd}~dSYd}~dSd}~wt$r�|���YdSxYwr$)�select�POLLINr%�POLLOUTr.�POLLPRIr1�POLLHUP�POLLERR�POLLNVAL�handle_close�OSError�errno�
_DISCONNECTEDr'r&)r)�flags�es   r�	readwriterAnsT����6�=� �	$��!�!�#�#�#��6�>�!�	%��"�"�$�$�$��6�>�!�	$��!�!�#�#�#��F�N�V�^�3�f�o�E�F�	���������	�	�������7�-�'�'��������������������
���������� ����
�������������s�B&B,�,
D�67C9�9#D�c��|�t}|�rog}g}g}t|�����D]{\}}|���}|���}|r|�|��|r|js|�|��|s|r|�|���|g|cxkr
|cxkr|krnntj|��dStj	||||��\}}}|D])}|�
|��}|��t|���*|D])}|�
|��}|��t|���*|D]+}|�
|��}|��t|���*dSdSr$)�
socket_map�list�items�readable�writable�append�	accepting�time�sleepr4�getr*r/r2)	�timeout�map�r�wr@�fdr)�is_r�is_ws	         r�pollrU�s���
�{���
�"���B��B���C�I�I�K�K�(�(�		�		�G�B���<�<�>�>�D��<�<�>�>�D��
���������
�C�M�
���������
�t�
���������
������a�����1�������J�w�����F��-��1�a��1�1���1�a��	�	�B��'�'�"�+�+�C��{����I�I�I�I��	�	�B��'�'�"�+�+�C��{���#�J�J�J�J��	�	�B��'�'�"�+�+�C��{���s�O�O�O�O�E"�"�<	�	r"c�.�|�t}|�t|dz��}tj��}|r�t	|�����D]y\}}d}|���r|tjtjzz}|�	��r|j
s|tjz}|r|�||���z|�|��}|D]/\}}|�
|��}|��t||���.dSdS)Ni�r)rD�intr4rUrErFrGr5r7rHrJr6�registerrMrA)rNrO�pollsterrRr)r?rPs       r�poll2rZ�s'��
�{������g�d�l�#�#���{�}�}�H�
�"��C�I�I�K�K�(�(�	-�	-�G�B���E��|�|�~�~�
8������7�7���|�|�~�~�
(�c�m�
(����'���
-��!�!�"�e�,�,�,���M�M�'�"�"���	"�	"�I�B���'�'�"�+�+�C��{���c�5�!�!�!�!�!"�"�	"�	"r"�>@Fc���|�t}|rttd��rt}nt}|�|r|||��|�dSdS|r!|dkr|||��|dz
}|r
|dk�dSdSdSdS)NrUr�)rD�hasattrr4rZrU)rN�use_pollrO�count�poll_funs     r�looprb�s���
�{�����G�F�F�+�+��������}��	#��H�W�c�"�"�"��	#�	#�	#�	#�	#��	�e�a�i�i��H�W�c�"�"�"��A�I�E��	�e�a�i�i�i�i�	�	�	�	�i�ir"c��eZdZdZdZdZdZdZdZe	dh��Z
d#d�Zd�Zd$d�Z
d$d�Zejejfd�Zd$d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd%d�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d �Z)d!�Z*d"�Z+dS)&�
dispatcherFN�warningc��|�
t|_n||_d|_|r�|�d��|�||��d|_	|���|_dS#t$r>}|j	ttfvrd|_n|�|���Yd}~dSd}~wwxYwd|_
dS)NFT)rD�_map�_fileno�setblocking�
set_socket�	connected�getpeername�addrr<r=rr�del_channel�socket)�self�sockrOrs    r�__init__zdispatcher.__init__�s����;�"�D�I�I��D�I�����	�
���U�#�#�#��O�O�D�#�&�&�&�!�D�N�
� �,�,�.�.��	�	�	���

�

�

��9��6� 2�2�2�&+�D�N�N�
�$�$�S�)�)�)��
#�N�N�N�N�N�����	

�����D�K�K�Ks�A.�.
B6�83B1�1B6c���|jjdz|jjzg}|jr|jr|�d��n|jr|�d��|j�V	|�d|jz��n7#t$r*|�t|j����YnwxYwdd�	|��t|��fzS)N�.�	listeningrkz%s:%dz<%s at %#x>� )�	__class__rr rJrmrIrk�	TypeError�repr�join�id)rp�statuss  r�__repr__zdispatcher.__repr__s����.�+�C�/���0K�K�L���>�	'�d�i�	'��M�M�+�&�&�&�&�
�^�	'��M�M�+�&�&�&��9� �
/��
�
�g��	�1�2�2�2�2���
/�
/�
/��
�
�d�4�9�o�o�.�.�.�.�.�
/��������� 0� 0�"�T�(�(�;�;�;s�&B�1B8�7B8c�,�|�|j}|||j<dSr$)rgrh)rprOs  r�add_channelzdispatcher.add_channels ���;��)�C� ��D�L���r"c�B�|j}|�|j}||vr||=d|_dSr$)rhrg)rprOrRs   rrnzdispatcher.del_channels0��
�\���;��)�C�
��9�9��B������r"c��||f|_tj||��}|�d��|�|��dS�NF)�family_and_typerorirj)rp�family�typerqs    r�
create_socketzdispatcher.create_socketsK��%�t�|����}�V�T�*�*�����������������r"c�p�||_|���|_|�|��dSr$)ro�filenorhr�rprqrOs   rrjzdispatcher.set_socket#s2������{�{�}�}�����������r"c���	|j�tjtj|j�tjtj��dz��dS#t
$rYdSwxYw)Nr])ro�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�
getsockoptr<�rps r�set_reuse_addrzdispatcher.set_reuse_addr(s���	��K�"�"��!�6�#6���&�&�v�'8�'-�':�<�<�>?�@�
�
�
�
�
��
�	�	�	��D�D�	���s�A A$�$
A2�1A2c��dS�NTr!r�s rrGzdispatcher.readable9����tr"c��dSr�r!r�s rrHzdispatcher.writable<r�r"c�t�d|_tjdkr|dkrd}|j�|��S)NT�nt�)rJr�namero�listen)rp�nums  rr�zdispatcher.listenCs7�����
�7�d�?�?�s�Q�w�w��C��{�!�!�#�&�&�&r"c�D�||_|j�|��Sr$)rmro�bind)rprms  rr�zdispatcher.bindIs����	��{����%�%�%r"c�L�d|_d|_|j�|��}|tt
tfvs|tkrtj	dkr	||_
dS|dtfvr||_
|���dSt|t|���)NFTr�r)rk�
connectingro�
connect_exrrrrrr�rmr
�handle_connect_eventr<r)rp�addressrs   r�connectzdispatcher.connectMs����������k�$�$�W�-�-���;��+�6�6�6��&�=�=�R�W��_�_��D�I��F��1�g�,����D�I��%�%�'�'�'�'�'��#�y��~�.�.�.r"c���	|j���\}}||fS#t$rYdSt$r'}|jt
ttfvrYd}~dS�d}~wwxYwr$)ro�acceptrxr<r=rrr)rp�connrm�whys    rr�zdispatcher.accept[s���
	���+�+�-�-�J�D�$���:����	�	�	��4�4��	�	�	��y�[�,��?�?�?��t�t�t�t�t������		���s�"�
A�	A�A�A�Ac���	|j�|��}|S#t$rD}|jtkrYd}~dS|jt
vr|���Yd}~dS�d}~wwxYw�Nr)ro�sendr<r=rr>r;)rp�data�resultr�s    rr�zdispatcher.sendis���
	��[�%�%�d�+�+�F��M���	�	�	��y�K�'�'��q�q�q�q�q���m�+�+��!�!�#�#�#��q�q�q�q�q������	���s��
A,�A'�"A'�&A'�'A,c���	|j�|��}|s|���dS|S#t$r.}|jt
vr|���Yd}~dS�d}~wwxYw�Nr")ro�recvr;r<r=r>)rp�buffer_sizer�r�s    rr�zdispatcher.recvvs���	��;�#�#�K�0�0�D��
��!�!�#�#�#��s�����	�	�	��y�M�)�)��!�!�#�#�#��s�s�s�s�s������
	���s�06�6�
A.�"A)�(A)�)A.c��d|_d|_d|_|���|j�J	|j���dS#t$r!}|jttfvr�Yd}~dSd}~wwxYwdSr�)
rkrJr�rnro�closer<r=rr)rpr�s  rr�zdispatcher.close�s�������������������;�"�
���!�!�#�#�#�#�#���
�
�
��9�X�u�$5�5�5��6�5�5�5�5�5�����
����#�"s�A
�
A8�A3�3A8c�d�tj�dt|��z��dS)Nzlog: %s
)�sys�stderrr/�str)rp�messages  r�logzdispatcher.log�s)���
����s�7�|�|�3�4�4�4�4�4r"�infoc�D�||jvrt|�d|����dSdS)Nz: )�ignore_log_types�print)rpr�r�s   r�log_infozdispatcher.log_info�s7���t�,�,�,��d�d�d�G�G�,�-�-�-�-�-�-�,r"c���|jr|���dS|js1|jr|���|���dS|���dSr$)rJ�
handle_acceptrkr�r��handle_readr�s rr%zdispatcher.handle_read_event�s|���>�		�
��� � � � � ���	���
,��)�)�+�+�+����������������r"c���|j�tjtj��}|dkrt	|t|�����|���d|_d|_dS)NrTF)	ror�r��SO_ERRORr<r�handle_connectrkr��rprs  rr�zdispatcher.handle_connect_event�sa���k�$�$�V�%6���H�H���!�8�8��#�y��~�~�.�.�.��������������r"c��|jrdS|js|jr|���|���dSr$)rJrkr�r��handle_writer�s rr.zdispatcher.handle_write_event�sQ���>�	�
�F��~�	,���
,��)�)�+�+�+��������r"c���|j�tjtj��}|dkr|���dS|���dSr�)ror�r�r�r;�handle_exptr�s  rr1zdispatcher.handle_expt_event�s[���k�$�$�V�%6���H�H���!�8�8�
���������������r"c���t��\}}}}	t|��}n#dt|��z}YnxYw|�d|�d|�d|�d|�d�	d��|���dS)Nz)<__repr__(self) failed for object at %0x>z-uncaptured python exception, closing channel z (�:rv�)�error)�compact_tracebackryr{r�r;)rp�nil�t�v�tbinfo�	self_reprs      rr'zdispatcher.handle_error�s���-�/�/���Q��6�	O��T�
�
�I�I��	O�C�b��h�h�N�I�I�I�����
�
�
��	�	����������	
�
�	�	�	�	
�������s�%�;c�2�|�dd��dS)Nz!unhandled incoming priority eventre�r�r�s rr�zdispatcher.handle_expt�s���
�
�9�9�E�E�E�E�Er"c�2�|�dd��dS)Nzunhandled read eventrer�r�s rr�zdispatcher.handle_read�s���
�
�,�i�8�8�8�8�8r"c�2�|�dd��dS)Nzunhandled write eventrer�r�s rr�zdispatcher.handle_write�s���
�
�-�y�9�9�9�9�9r"c�2�|�dd��dS)Nzunhandled connect eventrer�r�s rr�zdispatcher.handle_connect�s���
�
�/��;�;�;�;�;r"c�J�|���}|�|j|�dSdSr$)r��handle_accepted)rp�pairs  rr�zdispatcher.handle_accept�s3���{�{�}�}���� �D� �$�'�'�'�'��r"c�Z�|���|�dd��dS)Nzunhandled accepted eventre)r�r�)rprqrms   rr�zdispatcher.handle_accepted�s*���
�
�����
�
�0�)�<�<�<�<�<r"c�Z�|�dd��|���dS)Nzunhandled close eventre)r�r�r�s rr;zdispatcher.handle_close�s(���
�
�-�y�9�9�9��
�
�����r"�NNr$)r�),rrr �debugrkrJr��closingrm�	frozensetr�rrr}rrnro�AF_INET�SOCK_STREAMr�rjr�rGrHr�r�r�r�r�r�r�r�r�r%r�r.r1r'r�r�r�r�r�r�r;r!r"rrdrd�s4�������E��I��I��J��G��D� �y�)��-�-������@<�<�<�!�!�!�!�����$*�>��8J���������
	�	�	�"������'�'�'�&�&�&�/�/�/����������$
�
�
� 5�5�5�.�.�.�.�
�
�
� � � �	�	�	�
�
�
����(F�F�F�9�9�9�:�:�:�<�<�<�(�(�(�
=�=�=�����r"rdc�.�eZdZdd�Zd�Zd�Zd�Zd�ZdS)�dispatcher_with_sendNc�L�t�|||��d|_dSr�)rdrr�
out_bufferr�s   rrrzdispatcher_with_send.__init__s%�����D�$��,�,�,�����r"c��d}t�||jdd���}|j|d�|_dS)Nri)rdr�r�)rp�num_sents  r�
initiate_sendz"dispatcher_with_send.initiate_sends;�����?�?�4����%��)@�A�A���/�(�)�)�4����r"c�.�|���dSr$)r�r�s rr�z!dispatcher_with_send.handle_write
s���������r"c�:�|jpt|j��Sr$)rk�lenr�r�s rrHzdispatcher_with_send.writable
s���N�"�;�s�4�?�';�';�;r"c��|jr%|�dt|��z��|j|z|_|���dS)Nz
sending %s)r�r�ryr�r�)rpr�s  rr�zdispatcher_with_send.sendsO���:�	5��M�M�,��d���3�4�4�4��/�D�0����������r"r�)rrr rrr�r�rHr�r!r"rr�r��sd����������5�5�5�
���<�<�<�����r"r�c�f�tj��\}}}g}|std���|rQ|�|jjj|jjjt|j	��f��|j
}|�Q~|d\}}}d�d�|D����}|||f|||fS)Nztraceback does not exist���rvc��g|]}d|z��S)z
[%s|%s|%s]r!)�.0�xs  r�
<listcomp>z%compact_traceback.<locals>.<listcomp>+s��6�6�6�!�\�A�%�6�6�6r")r��exc_info�AssertionErrorrI�tb_frame�f_code�co_filename�co_namer��	tb_lineno�tb_nextrz)r�r��tbr��file�function�liner�s        rr�r�s����|�~�~�H�A�q�"�
�F�
�9��7�8�8�8�
���
�
��K��*��K��&�������	�	�	�
�Z��

��	�!�"�:��D�(�D��8�8�6�6�v�6�6�6�7�7�D��(�D�!�1�a��-�-r"c�&�|�t}t|�����D]Q}	|����#t$r}|jtkrn|s�Yd}~�;d}~wt$r�|s�Y�OxYw|���dSr$)	rDrE�valuesr�r<r=rr&�clear)rO�
ignore_allr�s   r�	close_allr.s���
�{���
�#�*�*�,�,�
�
����	�
�G�G�I�I�I�I���	�	�	��w�%�����
�����������#�	�	�	��	��
��
�
�����I�I�K�K�K�K�Ks�A�
A:�
A&�&A:�posixc�B�eZdZd�Zd�Zd�Zd�Zd	d�ZeZeZ	d�Z
d�ZdS)
�file_wrapperc�8�tj|��|_dSr$)r�duprR�rprRs  rrrzfile_wrapper.__init__Ss���f�R�j�j�D�G�G�Gr"c��|jdkrtjd|zt|���|���dS)Nrzunclosed file %r)�source)rR�warnings�warn�ResourceWarningr�r�s r�__del__zfile_wrapper.__del__VsD���w�!�|�|��
�0�4�7��%)�+�+�+�+��J�J�L�L�L�L�Lr"c�0�tj|jg|�R�Sr$)rr*rR�rp�argss  rr�zfile_wrapper.recv\s���7�4�7�*�T�*�*�*�*r"c�0�tj|jg|�R�Sr$)rr/rRrs  rr�zfile_wrapper.send_s���8�D�G�+�d�+�+�+�+r"Nc�h�|tjkr|tjkr|sdStd���)Nrz-Only asyncore specific behaviour implemented.)ror�r��NotImplementedError)rp�level�optname�buflens    rr�zfile_wrapper.getsockoptbsA����*�*�*��6�?�*�*��+��q�%�'5�6�6�
6r"c�d�|jdkrdS|j}d|_tj|��dS)Nrr�)rRrr�r	s  rr�zfile_wrapper.closems1���w��{�{�����B��D�G��H�R�L�L�L�L�Lr"c��|jSr$)rRr�s rr�zfile_wrapper.filenots	���7�Nr"r$)rrr rrrr�r�r�r*r/r�r�r!r"rrrNs�������
	!�	!�	!�	�	�	�	+�	+�	+�	,�	,�	,�	6�	6�	6�	6�����	�	�	�	�	�	�	�	r"rc��eZdZdd�Zd�ZdS)�file_dispatcherNc���t�|d|��d|_	|���}n#t$rYnwxYw|�|��t
j|d��dS)NTF)rdrrrkr��AttributeError�set_filer�set_blocking)rprRrOs   rrrzfile_dispatcher.__init__ys������d�C�0�0�0�!�D�N�
��Y�Y�[�[����!�
�
�
���
�����M�M�"�����O�B��&�&�&�&�&s�:�
A�Ac��t|��|_|j���|_|���dSr$)rror�rhrr	s  rrzfile_dispatcher.set_file�s>��&�r�*�*�D�K��;�-�-�/�/�D�L��������r"r$)rrr rrrr!r"rrrws7������		'�		'�		'�		'�	�	�	�	�	r"r)rBN)r[FNNr�)1�__doc__r4ror�rKrrr=rrrrrrr	r
rrr
rr�_DEPRECATION_MSG�_deprecatedrr�r>rDrr�	Exceptionr�KeyboardInterrupt�
SystemExitr&r*r/r2rArUrZ�poll3rbrdr�r�rr�rrr!r"r�<module>r)s��8��*�
�
�
�
�
�
�
�
�
�
�
���������	�	�	�	�������������������������������N�����X�/��@�@�@�@��	�:�x��L�%� �"�#�#�
���J�J�������J�J�J�����'�'�'�	�	�	�	�	�i�	�	�	� �!2�J�?��������������(%�%�%�%�N"�"�"�"�4	������$a�a�a�a�a�a�a�a�P	�����:����6.�.�.�(����>�7�g���'�'�'�'�'�'�'�'�R�����*������U�s� A#�#A-�,A-