Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 1 | .. currentmodule:: asyncio |
| 2 | |
| 3 | |
Yury Selivanov | 7372c3b | 2018-09-14 15:11:24 -0700 | [diff] [blame] | 4 | .. _asyncio-exceptions: |
| 5 | |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 6 | ========== |
| 7 | Exceptions |
| 8 | ========== |
| 9 | |
Kyle Stanley | f900064 | 2019-10-10 19:18:46 -0400 | [diff] [blame] | 10 | **Source code:** :source:`Lib/asyncio/exceptions.py` |
| 11 | |
| 12 | ---------------------------------------------------- |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 13 | |
| 14 | .. exception:: TimeoutError |
| 15 | |
| 16 | The operation has exceeded the given deadline. |
| 17 | |
Yury Selivanov | 7372c3b | 2018-09-14 15:11:24 -0700 | [diff] [blame] | 18 | .. important:: |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 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 | |
Carol Willing | a3c8ba7 | 2018-09-13 16:14:41 -0700 | [diff] [blame] | 27 | This exception can be caught to perform custom operations |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 28 | when asyncio Tasks are cancelled. In almost all situations the |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 29 | exception must be re-raised. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 30 | |
Xtreak | 7b69069 | 2019-09-11 15:12:51 +0100 | [diff] [blame] | 31 | .. versionchanged:: 3.8 |
Carol Willing | a3c8ba7 | 2018-09-13 16:14:41 -0700 | [diff] [blame] | 32 | |
Xtreak | 7b69069 | 2019-09-11 15:12:51 +0100 | [diff] [blame] | 33 | :exc:`CancelledError` is now a subclass of :class:`BaseException`. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 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 | |
Carol Willing | a3c8ba7 | 2018-09-13 16:14:41 -0700 | [diff] [blame] | 46 | The "sendfile" syscall is not available for the given |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 47 | socket or file type. |
| 48 | |
| 49 | A subclass of :exc:`RuntimeError`. |
| 50 | |
| 51 | |
| 52 | .. exception:: IncompleteReadError |
| 53 | |
Andre Delfino | 11205b8 | 2019-03-10 08:02:17 -0300 | [diff] [blame] | 54 | The requested read operation did not complete fully. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 55 | |
Andre Delfino | 11205b8 | 2019-03-10 08:02:17 -0300 | [diff] [blame] | 56 | Raised by the :ref:`asyncio stream APIs<asyncio-streams>`. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 57 | |
Andre Delfino | 11205b8 | 2019-03-10 08:02:17 -0300 | [diff] [blame] | 58 | This exception is a subclass of :exc:`EOFError`. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 59 | |
| 60 | .. attribute:: expected |
| 61 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 62 | The total number (:class:`int`) of expected bytes. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 63 | |
| 64 | .. attribute:: partial |
| 65 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 66 | A string of :class:`bytes` read before the end of stream was reached. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 67 | |
| 68 | |
| 69 | .. exception:: LimitOverrunError |
| 70 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 71 | Reached the buffer size limit while looking for a separator. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 72 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 73 | Raised by the :ref:`asyncio stream APIs <asyncio-streams>`. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 74 | |
| 75 | .. attribute:: consumed |
| 76 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame] | 77 | The total number of to be consumed bytes. |