PEP 475: update the list of modified functions according to the implementation
Mention also the special case of socket.socket.connect().
This commit is contained in:
parent
6c32726275
commit
c170883653
81
pep-0475.txt
81
pep-0475.txt
|
@ -168,37 +168,74 @@ Modified functions
|
|||
Example of standard library functions that need to be modified to comply
|
||||
with this PEP:
|
||||
|
||||
* ``open()``, ``os.open()``
|
||||
* ``os.read()``, ``io.FileIO.read()``, ``io.FileIO.readinto()``
|
||||
* ``os.write()``, ``io.FileIO.write()``
|
||||
* ``os.waitpid()``
|
||||
* ``socket.accept()``
|
||||
* ``socket.connect()``
|
||||
* ``socket.recv()``, ``socket.recv_into()``
|
||||
* ``socket.recv_from()``
|
||||
* ``socket.send()``
|
||||
* ``socket.sendto()``
|
||||
* ``time.sleep()``
|
||||
* ``select.select()``
|
||||
* ``select.poll()``
|
||||
* ``select.epoll.poll()``
|
||||
* ``select.devpoll.poll()``
|
||||
* ``select.kqueue.control()``
|
||||
* ``selectors.SelectSelector.select()`` and other selector classes
|
||||
* ``open()``, ``os.open()``, ``io.open()``
|
||||
* functions of the ``faulthandler`` module
|
||||
* ``os`` functions:
|
||||
|
||||
(note: the ``selector`` module already retries on ``InterruptedError``, but it
|
||||
- ``os.fchdir()``
|
||||
- ``os.fchmod()``
|
||||
- ``os.fchown()``
|
||||
- ``os.fdatasync()``
|
||||
- ``os.fstat()``
|
||||
- ``os.fstatvfs()``
|
||||
- ``os.fsync()``
|
||||
- ``os.ftruncate()``
|
||||
- ``os.mkfifo()``
|
||||
- ``os.mknod()``
|
||||
- ``os.posix_fadvise()``
|
||||
- ``os.posix_fallocate()``
|
||||
- ``os.pread()``
|
||||
- ``os.pwrite()``
|
||||
- ``os.read()``
|
||||
- ``os.readv()``
|
||||
- ``os.sendfile()``
|
||||
- ``os.wait3()``
|
||||
- ``os.wait4()``
|
||||
- ``os.wait()``
|
||||
- ``os.waitid()``
|
||||
- ``os.waitpid()``
|
||||
- ``os.write()``
|
||||
- ``os.writev()``
|
||||
- special cases: ``os.close()`` and ``os.dup2()`` now ignore ``EINTR`` error,
|
||||
the syscall is not retried
|
||||
|
||||
* ``select.select()``, ``select.poll.poll()``, ``select.epoll.poll()``,
|
||||
``select.kqueue.control()``, ``select.devpoll.poll()``
|
||||
* ``socket.socket()`` methods:
|
||||
|
||||
- ``accept()``
|
||||
- ``connect()`` (except for non-blocking sockets)
|
||||
- ``recv()``
|
||||
- ``recvfrom()``
|
||||
- ``recvmsg()``
|
||||
- ``send()``
|
||||
- ``sendall()``
|
||||
- ``sendmsg()``
|
||||
- ``sendto()``
|
||||
|
||||
* ``signal.sigtimedwait()``, ``signal.sigwaitinfo()``
|
||||
* ``time.sleep()``
|
||||
|
||||
(Note: the ``selector`` module already retries on ``InterruptedError``, but it
|
||||
doesn't recompute the timeout yet)
|
||||
|
||||
``os.close`` and ``close()`` methods are a special case: they will ignore
|
||||
EINTR instead of retrying. The reason is complex but involves behaviour
|
||||
under Linux and the fact that the file descriptor may really be closed
|
||||
even if EINTR is returned. See articles:
|
||||
``os.close``, ``close()`` methods and ``os.dup2()`` are a special case: they
|
||||
will ignore ``EINTR`` instead of retrying. The reason is complex but involves
|
||||
behaviour under Linux and the fact that the file descriptor may really be
|
||||
closed even if EINTR is returned. See articles:
|
||||
|
||||
* `Returning EINTR from close() <http://lwn.net/Articles/576478/>`_
|
||||
* `(LKML) Re: [patch 7/7] uml: retry host close() on EINTR
|
||||
<http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html>`_
|
||||
* `close() and EINTR <http://alobbs.com/post/54503240599/close-and-eintr>`_
|
||||
|
||||
The ``socket.socket.connect()`` method does not retry ``connect()`` for
|
||||
non-blocking sockets if it is interrupted by a signal (fails with ``EINTR``).
|
||||
The connection runs asynchronously in background. The caller is responsible
|
||||
to wait until the socket becomes writable (ex: using ``select.select()``)
|
||||
and then call ``socket.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)``
|
||||
to check if the connection succeeded (``getsockopt()`` returns ``0``) or failed.
|
||||
|
||||
|
||||
InterruptedError handling
|
||||
-------------------------
|
||||
|
|
Loading…
Reference in New Issue