Like :meth:`.add_callback()`, but handles error cases. An Exception instance will be passed as the first positional argument to `fn`.
(self, fn, *args, **kwargs)
| 5105 | return self |
| 5106 | |
| 5107 | def add_errback(self, fn, *args, **kwargs): |
| 5108 | """ |
| 5109 | Like :meth:`.add_callback()`, but handles error cases. |
| 5110 | An Exception instance will be passed as the first positional argument |
| 5111 | to `fn`. |
| 5112 | """ |
| 5113 | run_now = False |
| 5114 | with self._callback_lock: |
| 5115 | # Always add fn to self._errbacks, even when we're about to execute |
| 5116 | # it, to prevent races with functions like start_fetching_next_page |
| 5117 | # that reset _final_exception |
| 5118 | self._errbacks.append((fn, args, kwargs)) |
| 5119 | if self._final_exception: |
| 5120 | run_now = True |
| 5121 | if run_now: |
| 5122 | fn(self._final_exception, *args, **kwargs) |
| 5123 | return self |
| 5124 | |
| 5125 | def add_callbacks(self, callback, errback, |
| 5126 | callback_args=(), callback_kwargs=None, |
no outgoing calls