Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
writer.cpython-313.pyc77 linesDownload Raw Back to __pycache__
1�

2��j-����%SrSSKrSSKrSSKrSSKJr SSKJrJrJ	r	J3r4 SSKJr SSK
Jr SSKJrJr S	S5KJrJrJrJrJrJrJrJr S	SKJrJr Sr\\\ S
'Sr!\\\ S'Sr""SS5r#g)z%WebSocket protocol versions 13 and 8.�N)�partial)�Final�Optional�Set�Union�)�BaseProtocol)�ClientConnectionResetError)�ZLibBackend�ZLibCompressor�)�MASK_LEN�MSG_SIZE�PACK_CLOSE_CODE�	PACK_LEN1�	PACK_LEN2�	PACK_LEN3�
PACK_RANDBITS�websocket_mask)�WS_DEFLATE_TRAILING�	WSMsgType��
DEFAULT_LIMIT��WS_CONTROL_FRAME_OPCODEi@c�T�\rSrSrSrS\\R"5SSS.S\S\	RS\S	\S6\RS\S\S
S4Sjjr
SS\S\S\\S
S4SjjrS\S\S\S
S4SjrS\\S
\4SjrS\S\S\\S
S4SjrS\S\S\\S
S4SjrSS\S\\\4S
S4SjjrSrg)�WebSocketWriter�(aWebSocket writer.7 8The writer is responsible for sending messages to the client. It is9created by the protocol when a connection is established. The writer10should avoid implementing any application logic and should only be11concerned with the low-level details of the WebSocket protocol.12Fr)�use_mask�limit�random�compress�13notakeover�protocol�	transportrr r!r"r#�returnNc���XlX lX0l[URS5UlX`lXplSUlX@l	SUl14SUl[R"5Ul[5Ulg)zInitialize a WebSocket writer.� FrN)r$r%rr�getrandbits�get_random_bitsr"r#�_closing�_limit�_output_size�_compressobj�asyncio�Lock�15_send_lock�set�_background_tasks)�selfr$r%rr r!r"r#s        �_D:\code\apps\devtools\python\user_packages\Python313\site-packages\aiohttp/_websocket/writer.py�__init__�WebSocketWriter.__init__1se��!�
�"�� �
�&�v�'9�'9�2�>��� �
�$����
������6:���!�,�,�.���:=�%����message�opcodec���# �UR(a#U[R-(d[S5eU(dUR(a16U[17:�aUR
XS5 GO[U5[::a8URIShv�N URXU5 SSS5IShv�N O�[R"5nURXU5n[RS:�a[R "XTSS9nOUR#U5nUR$R'U5 UR)UR$R*5 [R,"U5IShv�N UR.UR0:�aFSUlUR2R4(a#UR2R75IShv�N gggGNIGN*!,IShv�N(df   N~=fN�N)7f)z<Send a frame over the websocket with message as its payload.�!Cannot write to closing transportrN)��T)�loop�eager_start)r+r�CLOSEr18r"r�_write_websocket_frame�len�WEBSOCKET_MAX_SYNC_CHUNK_SIZEr1�_send_compressed_frame_syncr/�get_running_loop�#_send_compressed_frame_async_locked�sys�version_info�Task�create_taskr3�add�add_done_callback�discard�shieldr-r,r$�_paused�
_drain_helper)r4r9r:r"r?�coro�	send_tasks       r5�19send_frame�WebSocketWriter.send_frameJsf����=�=�&�9�?�?�":�,�-P�Q�Q��D�M�M�f�8O�.O��'�'���;�
��\�:�
:�20�����0�0��(�K�'����+�+�-�D��;�;�G�X�V�D����7�*�#�L�L��d�K�	� �,�,�T�2�	��"�"�&�&�y�1��'�'��(>�(>�(F�(F�G��.�.��+�+�+����t�{�{�*� !�D���}�}�$�$��m�m�1�1�3�3�3�%�+�='�����*
,�4�sh�BG=�G�G=�G�'G=�2G�3CG=�3G9�4AG=�G;�G=�G=�G6�%G(�&G6�2G=�;G=�rsvc���[U5nURnU(aSOSnSU-U-nUS:a[XtU-5nSn	O+US:a[USU-U5nSn	O[	USU-U5nSn	UR21R
5(a[S	5eU(ai[UR55n22[U5n[X�5 UR23RX�-U-5 U=R[-
sl
O^U[:�a7UR24RU5 UR25RU5 OUR26RX�-5 U=RX�--
sl
g27)z�28Write a websocket frame to the transport.29 30This method handles frame header construction, masking, and writing to transport.31It does not handle compression or flow control - those are the responsibility32of the caller.33�r�~rr���34r<N)rCrrrrr%�35is_closingr36rr*�	bytearrayr�writer-rr)r4r9r:rV�37msg_lengthr�mask_bit�38first_byte�header�39header_len�masks           r5rB�&WebSocketWriter._write_websocket_frame|sI����\�40��=�=��#�4����C�Z�&�(�41�����z��+@�A�F��J�
�%�
��z�3��>�:�F�F��J��z�3��>�:�F�F��J��>�>�$�$�&�&�,�-P�Q�Q�� ��!5�!5�!7�8�D���(�G��4�)��N�N� � ����!8�9�����)��
�(�
"��N�N� � ��(��N�N� � ��)��N�N� � ��!1�2����Z�4�4�r8c���U(a[[RU*[S9$UR(d-[[RUR42*[S9UlUR$)zBGet or create a compressor object for the given compression level.)�level�wbits�max_sync_chunk_size)rr�Z_BEST_SPEEDrDr.r")r4r"s  r5�_get_compressor�WebSocketWriter._get_compressor�s^���!�!�.�.��i�$A��
�43� � � .�!�.�.��}�}�n�$A�!�D��44� � � r8c��URU5nURURU5URUR(a[45RO[46R5-R[5US5 g)z�47Synchronous send for small compressed frames.48 49This is used for small compressed payloads that compress synchronously in the event loop.50Since there are no await points, this is inherently cancellation-safe.51�@N)52rlrB�
compress_sync�flushr#r�Z_FULL_FLUSH�Z_SYNC_FLUSH�removesuffixr�r4r9r:r"�compressobjs     r5rE�+WebSocketWriter._send_compressed_frame_sync�ss���*�*�8�4��	
�#�#��)�)�'�2��#�#���� �,�,�$�1�1����l�.�/���	53r8c��# �URIShv�N URU5nURURU5IShv�NUR	UR54(a[RO[R5-R[5US5 SSS5IShv�N gN�NqN	!,IShv�N(df   g=f7f)a�55Async send for large compressed frames with lock.56 57Acquires the lock and compresses large payloads asynchronously in58the executor. The lock is held for the entire operation to ensure59the compressor state is not corrupted by concurrent sends.60 61MUST be run shielded from cancellation. If cancelled after62compression but before sending, the compressor state would be63advanced but data not sent, corrupting subsequent frames.64Nro)r1rlrBr"rqr#rrrrsrtrrus     r5rG�3WebSocketWriter._send_compressed_frame_async_locked�s�����?�?�?��.�.�x�8�K�
�'�'�%�.�.�w�7�7�!�'�'��?�?�$�0�0�(�5�5����,�2�3���
�#�?�?�8�#�?�?�?�sW�C�B8�C�1B>�B:65�	AB>�'C�2B<�3C�:B>�<C�>C�C�C�C�codec���# �[U[5(aURS5nUR[	U5U-[66RS9IShv�N SUlgN!SUlf=f7f)z<Close the websocket, sending the specified code and message.zutf-8)r:NT)�67isinstance�str�encoderTrrrAr+)r4rzr9s   r5�close�WebSocketWriter.close�sk����g�s�#�#��n�n�W�-�G�	!��/�/���%��/�	���"��
�
�!�D�M�	
��!�D�M�s.�'A2�-A&�A$�A&�A2�$A&�&	A/�/A2)r3r+r.r,r-r1r"r*r#r$r%r)N)i�r8)�__name__�68__module__�__qualname__�__firstlineno__�__doc__rr!�Randomr	r/�	Transport�bool�intr6�bytesrrTrBrrlrErGrr}r�__static_attributes__�r8r5rr(sj����"� &�
�
��� �@��@��$�$�@�69�@��
@��
�
�@��@��@�70�@�4FJ�04��04�&)�04�5=�c�]�04�	
�04�d05�e�05�S�05�s�05�t�05�d!���
�!�.�!�"71��72�&)�73�5=�c�]�74�	
�75�8 �� �&)� �5=�c�]� �	
� �D	!��	!�U�5�#�:�5F�	!�QU�	!�	!r8r)$r�r/r!rH�	functoolsr�typingrrrr�
base_protocolr	�client_exceptionsr76�compression_utilsrr�helpersrrrrrrrr�modelsrrrr��__annotations__rrDrr�r8r5�<module>r�sj��+��
�77��.�.�(�:�;�	�	�	�3�!�
�u�S�z�!�'(���s��'�!*��^!�^!r8
codekingpro/portable-devtools · Team Ai