File manager - Edit - /usr/lib/python3/dist-packages/twisted/internet/__pycache__/fdesc.cpython-310.pyc
Back
o �b� � @ s� d Z ddlZddlZzddlZW n ey dZY nw eZddlmZmZ dd� Z dd� Z edu r9dd � ZZnd d� Zdd � Zdd� Z dd� Zg d�ZdS )z< Utility functions for dealing with POSIX file descriptors. � N)�CONNECTION_DONE�CONNECTION_LOSTc C s, t � | t j�}|tjB }t � | t j|� dS )zP Set the file description of the given file descriptor to non-blocking. N��fcntl�F_GETFL�os� O_NONBLOCK�F_SETFL��fd�flags� r �8/usr/lib/python3/dist-packages/twisted/internet/fdesc.py�setNonBlocking � r c C s. t � | t j�}|tj @ }t � | t j|� dS )zL Set the file description of the given file descriptor to blocking. Nr r r r r �setBlocking! � r c C s d S )Nr )r r r r �<lambda>- s r c C s, t � | t j�}|t jB }t � | t j|� dS �z7 Make a file descriptor close-on-exec. N�r �F_GETFD� FD_CLOEXEC�F_SETFDr r r r �_setCloseOnExec0 r r c C s. t � | t j�}|t j @ }t � | t j|� dS r r r r r r �_unsetCloseOnExec8 r r c C sr zt �| d�}W n& ty. } z|jd tjtjfv r"W Y d}~dS tW Y d}~S d}~ww |s3tS ||� dS )a Read from file descriptor, calling callback with resulting data. If successful, call 'callback' with a single argument: the resulting data. Returns same thing FileDescriptor.doRead would: CONNECTION_LOST, CONNECTION_DONE, or None. @type fd: C{int} @param fd: non-blocking file descriptor to be read from. @param callback: a callable which accepts a single argument. If data is read from the file descriptor it will be called with this data. Handling exceptions from calling the callback is up to the caller. Note that if the descriptor is still connected but no data is read, None will be returned but callback will not be called. @return: CONNECTION_LOST on error, CONNECTION_DONE when fd is closed, otherwise None. i r N) r �read�OSError�args�errno�EAGAIN�EINTRr r )r �callback�output�ioer r r � readFromFDA s ��r$ c C sX zt �| |�W S ty+ } z|jtjtjfv rW Y d}~dS tW Y d}~S d}~ww )a> Write data to file descriptor. Returns same thing FileDescriptor.writeSomeData would. @type fd: C{int} @param fd: non-blocking file descriptor to be written to. @type data: C{str} or C{buffer} @param data: bytes to write to fd. @return: number of bytes written, or CONNECTION_LOST. Nr )r �writer r r r r )r �data�ior r r � writeToFDd s ��r( )r r r$ r( )�__doc__r r r �_fcntl�ImportError�twisted.internet.mainr r r r r r r$ r( �__all__r r r r �<module> s&