blob: b1e6ecfda15ead2638ed953bcee224e443a6267a [file] [log] [blame]
Yury Selivanov7c7605f2018-09-11 09:54:40 -07001.. currentmodule:: asyncio
2
3
Yury Selivanov7372c3b2018-09-14 15:11:24 -07004.. _asyncio-exceptions:
5
Yury Selivanov7c7605f2018-09-11 09:54:40 -07006==========
7Exceptions
8==========
9
10
11.. exception:: TimeoutError
12
13 The operation has exceeded the given deadline.
14
Yury Selivanov7372c3b2018-09-14 15:11:24 -070015 .. important::
Yury Selivanov7c7605f2018-09-11 09:54:40 -070016 This exception is different from the builtin :exc:`TimeoutError`
17 exception.
18
19
20.. exception:: CancelledError
21
22 The operation has been cancelled.
23
Carol Willinga3c8ba72018-09-13 16:14:41 -070024 This exception can be caught to perform custom operations
Yury Selivanov7c7605f2018-09-11 09:54:40 -070025 when asyncio Tasks are cancelled. In almost all situations the
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040026 exception must be re-raised.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070027
Xtreak7b690692019-09-11 15:12:51 +010028 .. versionchanged:: 3.8
Carol Willinga3c8ba72018-09-13 16:14:41 -070029
Xtreak7b690692019-09-11 15:12:51 +010030 :exc:`CancelledError` is now a subclass of :class:`BaseException`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070031
32
33.. exception:: InvalidStateError
34
35 Invalid internal state of :class:`Task` or :class:`Future`.
36
37 Can be raised in situations like setting a result value for a
38 *Future* object that already has a result value set.
39
40
41.. exception:: SendfileNotAvailableError
42
Carol Willinga3c8ba72018-09-13 16:14:41 -070043 The "sendfile" syscall is not available for the given
Yury Selivanov7c7605f2018-09-11 09:54:40 -070044 socket or file type.
45
46 A subclass of :exc:`RuntimeError`.
47
48
49.. exception:: IncompleteReadError
50
Andre Delfino11205b82019-03-10 08:02:17 -030051 The requested read operation did not complete fully.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070052
Andre Delfino11205b82019-03-10 08:02:17 -030053 Raised by the :ref:`asyncio stream APIs<asyncio-streams>`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070054
Andre Delfino11205b82019-03-10 08:02:17 -030055 This exception is a subclass of :exc:`EOFError`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070056
57 .. attribute:: expected
58
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040059 The total number (:class:`int`) of expected bytes.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070060
61 .. attribute:: partial
62
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040063 A string of :class:`bytes` read before the end of stream was reached.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070064
65
66.. exception:: LimitOverrunError
67
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040068 Reached the buffer size limit while looking for a separator.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070069
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040070 Raised by the :ref:`asyncio stream APIs <asyncio-streams>`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070071
72 .. attribute:: consumed
73
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040074 The total number of to be consumed bytes.