Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/anyio/_core/_exceptions.py: 81%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

16 statements  

1from __future__ import annotations 

2 

3 

4class BrokenResourceError(Exception): 

5 """ 

6 Raised when trying to use a resource that has been rendered unusable due to external 

7 causes (e.g. a send stream whose peer has disconnected). 

8 """ 

9 

10 

11class BrokenWorkerProcess(Exception): 

12 """ 

13 Raised by :func:`run_sync_in_process` if the worker process terminates abruptly or 

14 otherwise misbehaves. 

15 """ 

16 

17 

18class BusyResourceError(Exception): 

19 """ 

20 Raised when two tasks are trying to read from or write to the same resource 

21 concurrently. 

22 """ 

23 

24 def __init__(self, action: str): 

25 super().__init__(f"Another task is already {action} this resource") 

26 

27 

28class ClosedResourceError(Exception): 

29 """Raised when trying to use a resource that has been closed.""" 

30 

31 

32class DelimiterNotFound(Exception): 

33 """ 

34 Raised during 

35 :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_until` if the 

36 maximum number of bytes has been read without the delimiter being found. 

37 """ 

38 

39 def __init__(self, max_bytes: int) -> None: 

40 super().__init__( 

41 f"The delimiter was not found among the first {max_bytes} bytes" 

42 ) 

43 

44 

45class EndOfStream(Exception): 

46 """ 

47 Raised when trying to read from a stream that has been closed from the other end. 

48 """ 

49 

50 

51class IncompleteRead(Exception): 

52 """ 

53 Raised during 

54 :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_exactly` or 

55 :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_until` if the 

56 connection is closed before the requested amount of bytes has been read. 

57 """ 

58 

59 def __init__(self) -> None: 

60 super().__init__( 

61 "The stream was closed before the read operation could be completed" 

62 ) 

63 

64 

65class TypedAttributeLookupError(LookupError): 

66 """ 

67 Raised by :meth:`~anyio.TypedAttributeProvider.extra` when the given typed attribute 

68 is not found and no default value has been given. 

69 """ 

70 

71 

72class WouldBlock(Exception): 

73 """Raised by ``X_nowait`` functions if ``X()`` would block."""