blob: 7166d5c4bd88f9b155b6665ba0b512c28863b526 [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
Kyle Stanleyf9000642019-10-10 19:18:46 -040010**Source code:** :source:`Lib/asyncio/exceptions.py`
11
12----------------------------------------------------
Yury Selivanov7c7605f2018-09-11 09:54:40 -070013
14.. exception:: TimeoutError
15
16 The operation has exceeded the given deadline.
17
Yury Selivanov7372c3b2018-09-14 15:11:24 -070018 .. important::
Yury Selivanov7c7605f2018-09-11 09:54:40 -070019 This exception is different from the builtin :exc:`TimeoutError`
20 exception.
21
22
23.. exception:: CancelledError
24
25 The operation has been cancelled.
26
Carol Willinga3c8ba72018-09-13 16:14:41 -070027 This exception can be caught to perform custom operations
Yury Selivanov7c7605f2018-09-11 09:54:40 -070028 when asyncio Tasks are cancelled. In almost all situations the
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040029 exception must be re-raised.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070030
Xtreak7b690692019-09-11 15:12:51 +010031 .. versionchanged:: 3.8
Carol Willinga3c8ba72018-09-13 16:14:41 -070032
Xtreak7b690692019-09-11 15:12:51 +010033 :exc:`CancelledError` is now a subclass of :class:`BaseException`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070034
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
Carol Willinga3c8ba72018-09-13 16:14:41 -070046 The "sendfile" syscall is not available for the given
Yury Selivanov7c7605f2018-09-11 09:54:40 -070047 socket or file type.
48
49 A subclass of :exc:`RuntimeError`.
50
51
52.. exception:: IncompleteReadError
53
Andre Delfino11205b82019-03-10 08:02:17 -030054 The requested read operation did not complete fully.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070055
Andre Delfino11205b82019-03-10 08:02:17 -030056 Raised by the :ref:`asyncio stream APIs<asyncio-streams>`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070057
Andre Delfino11205b82019-03-10 08:02:17 -030058 This exception is a subclass of :exc:`EOFError`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070059
60 .. attribute:: expected
61
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040062 The total number (:class:`int`) of expected bytes.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070063
64 .. attribute:: partial
65
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040066 A string of :class:`bytes` read before the end of stream was reached.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070067
68
69.. exception:: LimitOverrunError
70
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040071 Reached the buffer size limit while looking for a separator.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070072
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040073 Raised by the :ref:`asyncio stream APIs <asyncio-streams>`.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070074
75 .. attribute:: consumed
76
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040077 The total number of to be consumed bytes.