Current File : //proc/self/root/kunden/lib/python3.9/site-packages/pymysql/__pycache__/_socketio.cpython-39.pyc |
a
B��Z� � @ 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 |dvrt d| ��tj�| � || _d|vr6|d7 }|| _d|v | _d|v | _d| _d S )N)�r�w�rw�rb�wbZrwbzinvalid mode: %r�br r F) �
ValueError�io� RawIOBase�__init__�_sock�_mode�_reading�_writing�_timeout_occurred)�selfZsock�mode� r �5/usr/lib/python3.9/site-packages/pymysql/_socketio.pyr
! s
zSocketIO.__init__c
C s� | � � | �� | jrtd��z| j�|�W S tyF d| _� Y q ty� } zB|jd }|t krrW Y d}~q|t
v r�W Y d}~dS � W Y d}~qd}~0 0 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 sf | � � | �� z| j�|�W S ty` } z*|jd tv rJW Y d}~dS � W Y d}~n
d}~0 0 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&