1.. currentmodule:: asyncio
2
3
4.. _asyncio-exceptions:
5
6==========
7Exceptions
8==========
9
10**Source code:** :source:`Lib/asyncio/exceptions.py`
11
12----------------------------------------------------
13
14.. exception:: TimeoutError
15
16   The operation has exceeded the given deadline.
17
18   .. important::
19      This exception is different from the builtin :exc:`TimeoutError`
20      exception.
21
22
23.. exception:: CancelledError
24
25   The operation has been cancelled.
26
27   This exception can be caught to perform custom operations
28   when asyncio Tasks are cancelled.  In almost all situations the
29   exception must be re-raised.
30
31   .. versionchanged:: 3.8
32
33      :exc:`CancelledError` is now a subclass of :class:`BaseException`.
34
35
36.. exception:: InvalidStateError
37
38   Invalid internal state of :class:`Task` or :class:`Future`.
39
40   Can be raised in situations like setting a result value for a
41   *Future* object that already has a result value set.
42
43
44.. exception:: SendfileNotAvailableError
45
46   The "sendfile" syscall is not available for the given
47   socket or file type.
48
49   A subclass of :exc:`RuntimeError`.
50
51
52.. exception:: IncompleteReadError
53
54   The requested read operation did not complete fully.
55
56   Raised by the :ref:`asyncio stream APIs<asyncio-streams>`.
57
58   This exception is a subclass of :exc:`EOFError`.
59
60   .. attribute:: expected
61
62      The total number (:class:`int`) of expected bytes.
63
64   .. attribute:: partial
65
66      A string of :class:`bytes` read before the end of stream was reached.
67
68
69.. exception:: LimitOverrunError
70
71   Reached the buffer size limit while looking for a separator.
72
73   Raised by the :ref:`asyncio stream APIs <asyncio-streams>`.
74
75   .. attribute:: consumed
76
77      The total number of to be consumed bytes.
78