2018-09-11 13:54:40 -03:00
|
|
|
.. currentmodule:: asyncio
|
|
|
|
|
|
|
|
|
2018-09-14 19:11:24 -03:00
|
|
|
.. _asyncio-exceptions:
|
|
|
|
|
2018-09-11 13:54:40 -03:00
|
|
|
==========
|
|
|
|
Exceptions
|
|
|
|
==========
|
|
|
|
|
2019-10-10 20:25:28 -03:00
|
|
|
**Source code:** :source:`Lib/asyncio/exceptions.py`
|
|
|
|
|
|
|
|
----------------------------------------------------
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
.. exception:: TimeoutError
|
|
|
|
|
|
|
|
The operation has exceeded the given deadline.
|
|
|
|
|
2018-09-14 19:11:24 -03:00
|
|
|
.. important::
|
2018-09-11 13:54:40 -03:00
|
|
|
This exception is different from the builtin :exc:`TimeoutError`
|
|
|
|
exception.
|
|
|
|
|
|
|
|
|
|
|
|
.. exception:: CancelledError
|
|
|
|
|
|
|
|
The operation has been cancelled.
|
|
|
|
|
2018-09-13 20:14:41 -03:00
|
|
|
This exception can be caught to perform custom operations
|
2018-09-11 13:54:40 -03:00
|
|
|
when asyncio Tasks are cancelled. In almost all situations the
|
2018-09-17 20:16:44 -03:00
|
|
|
exception must be re-raised.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
2019-09-11 12:08:47 -03:00
|
|
|
.. versionchanged:: 3.8
|
2018-09-11 13:54:40 -03:00
|
|
|
|
2019-09-11 12:08:47 -03:00
|
|
|
:exc:`CancelledError` is now a subclass of :class:`BaseException`.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. exception:: InvalidStateError
|
|
|
|
|
|
|
|
Invalid internal state of :class:`Task` or :class:`Future`.
|
|
|
|
|
|
|
|
Can be raised in situations like setting a result value for a
|
|
|
|
*Future* object that already has a result value set.
|
|
|
|
|
|
|
|
|
|
|
|
.. exception:: SendfileNotAvailableError
|
|
|
|
|
2018-09-13 20:14:41 -03:00
|
|
|
The "sendfile" syscall is not available for the given
|
2018-09-11 13:54:40 -03:00
|
|
|
socket or file type.
|
|
|
|
|
|
|
|
A subclass of :exc:`RuntimeError`.
|
|
|
|
|
|
|
|
|
|
|
|
.. exception:: IncompleteReadError
|
|
|
|
|
2019-03-10 08:02:17 -03:00
|
|
|
The requested read operation did not complete fully.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
2019-03-10 08:02:17 -03:00
|
|
|
Raised by the :ref:`asyncio stream APIs<asyncio-streams>`.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
2019-03-10 08:02:17 -03:00
|
|
|
This exception is a subclass of :exc:`EOFError`.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
.. attribute:: expected
|
|
|
|
|
2018-09-17 20:16:44 -03:00
|
|
|
The total number (:class:`int`) of expected bytes.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
.. attribute:: partial
|
|
|
|
|
2018-09-17 20:16:44 -03:00
|
|
|
A string of :class:`bytes` read before the end of stream was reached.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. exception:: LimitOverrunError
|
|
|
|
|
2018-09-17 20:16:44 -03:00
|
|
|
Reached the buffer size limit while looking for a separator.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
2018-09-17 20:16:44 -03:00
|
|
|
Raised by the :ref:`asyncio stream APIs <asyncio-streams>`.
|
2018-09-11 13:54:40 -03:00
|
|
|
|
|
|
|
.. attribute:: consumed
|
|
|
|
|
2018-09-17 20:16:44 -03:00
|
|
|
The total number of to be consumed bytes.
|