@@ -69,35 +69,48 @@ Please note: it is not POSIX time but a time with
69
69
undefined starting base, e.g. the time of the system power on.
70
70
71
71
72
- Context manager has ``.expired `` property for check if timeout happens
72
+ Context manager has ``.expired() `` / `` .expired `` for check if timeout happens
73
73
exactly in context manager::
74
74
75
75
async with timeout(1.5) as cm:
76
76
await inner()
77
- print(cm.expired)
77
+ print(cm.expired()) # recommended api
78
+ print(cm.expired) # compatible api
78
79
79
80
The property is ``True `` if ``inner() `` execution is cancelled by
80
81
timeout context manager.
81
82
82
83
If ``inner() `` call explicitly raises ``TimeoutError `` ``cm.expired ``
83
84
is ``False ``.
84
85
85
- The scheduled deadline time is available as ``.deadline `` property ::
86
+ The scheduled deadline time is available as ``.when() `` / `` .deadline `` ::
86
87
87
88
async with timeout(1.5) as cm:
88
- cm.deadline
89
+ cm.when() # recommended api
90
+ cm.deadline # compatible api
89
91
90
- Not finished yet timeout can be rescheduled by ``shift_by () ``
91
- or ``shift_to () `` methods::
92
+ Not finished yet timeout can be rescheduled by ``shift () ``
93
+ or ``update () `` methods::
92
94
93
95
async with timeout(1.5) as cm:
96
+ # recommended api
97
+ cm.reschedule(cm.when() + 1) # add another second on waiting
98
+ # compatible api
94
99
cm.shift(1) # add another second on waiting
95
100
cm.update(loop.time() + 5) # reschedule to now+5 seconds
96
101
97
102
Rescheduling is forbidden if the timeout is expired or after exit from ``async with ``
98
103
code block.
99
104
100
105
106
+ Disable scheduled timeout::
107
+
108
+ async with timeout(1.5) as cm:
109
+ cm.reschedule(None) # recommended api
110
+ cm.reject() # compatible api
111
+
112
+
113
+
101
114
Installation
102
115
------------
103
116
0 commit comments