| 90 | return self._cancelled |
| 91 | |
| 92 | def _run(self): |
| 93 | try: |
| 94 | self._context.run(self._callback, *self._args) |
| 95 | except (SystemExit, KeyboardInterrupt): |
| 96 | raise |
| 97 | except BaseException as exc: |
| 98 | cb = format_helpers._format_callback_source( |
| 99 | self._callback, self._args, |
| 100 | debug=self._loop.get_debug()) |
| 101 | msg = f'Exception in callback {cb}' |
| 102 | context = { |
| 103 | 'message': msg, |
| 104 | 'exception': exc, |
| 105 | 'handle': self, |
| 106 | } |
| 107 | if self._source_traceback: |
| 108 | context['source_traceback'] = self._source_traceback |
| 109 | self._loop.call_exception_handler(context) |
| 110 | self = None # Needed to break cycles when an exception occurs. |
| 111 | |
| 112 | # _ThreadSafeHandle is used for callbacks scheduled with call_soon_threadsafe |
| 113 | # and is thread safe unlike Handle which is not thread safe. |