Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True.
(self, msg=None)
| 154 | return exc |
| 155 | |
| 156 | def cancel(self, msg=None): |
| 157 | """Cancel the future and schedule callbacks. |
| 158 | |
| 159 | If the future is already done or cancelled, return False. Otherwise, |
| 160 | change the future's state to cancelled, schedule the callbacks and |
| 161 | return True. |
| 162 | """ |
| 163 | self.__log_traceback = False |
| 164 | if self._state != _PENDING: |
| 165 | return False |
| 166 | self._state = _CANCELLED |
| 167 | self._cancel_message = msg |
| 168 | self.__schedule_callbacks() |
| 169 | return True |
| 170 | |
| 171 | def __schedule_callbacks(self): |
| 172 | """Internal: Ask the event loop to call all callbacks. |