File: //opt/alt/python38/lib/python3.8/site-packages/pymysql/__pycache__/_socketio.cpython-38.opt-1.pyc
U
�
V� � @ sJ d Z ddlT ddlZddlZdgZejZejejfZG dd� dej �Z
dS )z}
SocketIO imported from socket module in Python 3.
Copyright (c) 2001-2013 Python Software Foundation; All Rights Reserved.
� )�*N�SocketIOc sp e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Z� fdd
�Z dd� Z
edd� �Zedd� �Z
dd� Z� ZS )r z�Raw I/O implementation for stream sockets.
This class supports the makefile() method on sockets. It provides
the raw I/O interface on top of a socket object.
c C sZ |dkrt d| ��tj�| � || _d|kr6|d7 }|| _d|k| _d|k| _d| _d S )N)�r�wZrw�rb�wbZrwbzinvalid mode: %r�br r F) �
ValueError�io� RawIOBase�__init__�_sock�_mode�_reading�_writing�_timeout_occurred)�selfZsock�mode� r �B/opt/alt/python38/lib/python3.8/site-packages/pymysql/_socketio.pyr ! s
zSocketIO.__init__c
C s� | � � | �� | jrtd��z| j�|�W S tk
rH d| _� Y q tk
r� } z2|jd }|t krrW Y �q|t
kr�W Y �
dS � W 5 d}~X Y qX qdS )a3 Read up to len(b) bytes into the writable buffer *b* and return
the number of bytes read. If the socket is non-blocking and no bytes
are available, None is returned.
If *b* is non-empty, a 0 return value indicates that the connection
was shutdown at the other end.
z!cannot read from timed out objectTr N)�_checkClosed�_checkReadabler �IOErrorr
Z recv_into�timeout�error�args�EINTR�_blocking_errnos)r r �e�nr r r �readinto- s
zSocketIO.readintoc
C s` | � � | �� z| j�|�W S tk
rZ } z|jd tkrHW Y �
dS � W 5 d}~X Y nX dS )a Write the given bytes or bytearray object *b* to the socket
and return the number of bytes written. This can be less than
len(b) if not all data could be written. If the socket is
non-blocking and no bytes could be written None is returned.
r N)r �_checkWritabler
�sendr r r )r r r r r r �writeG s
zSocketIO.writec C s | j rtd��| jS )z2True if the SocketIO is open for reading.
�I/O operation on closed socket.)�closedr r �r r r r �readableW s zSocketIO.readablec C s | j rtd��| jS )z2True if the SocketIO is open for writing.
r$ )r% r r r&