/usr/lib/python3/dist-packages/twisted/internet/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/internet/__pycache__/fdesc.cpython-310.pyc (3173B)
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 Ú
- 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 Ú s&