Stop recording task invocations, and return the trace as text. By default, the trace only shows those tasks that were invoked, because no up-to-date return value was available for them in the cache. But if the optional argument `verbose` is true then the trace will
(self, verbose=False)
| 25 | self._trace = [] |
| 26 | |
| 27 | def stop_tracing(self, verbose=False): |
| 28 | """Stop recording task invocations, and return the trace as text. |
| 29 | |
| 30 | By default, the trace only shows those tasks that were invoked, |
| 31 | because no up-to-date return value was available for them in the |
| 32 | cache. But if the optional argument `verbose` is true then the |
| 33 | trace will also include tasks which experienced a cache hit, not |
| 34 | of a miss, and therefore did not need to be re-invoked. |
| 35 | |
| 36 | """ |
| 37 | text = '\n'.join( |
| 38 | '{}{} {}'.format( |
| 39 | '. ' * depth, |
| 40 | 'calling' if not_available else 'returning cached', |
| 41 | task) |
| 42 | for (depth, not_available, task) in self._trace |
| 43 | if verbose or not_available) |
| 44 | |
| 45 | self._trace = None |
| 46 | return text |
| 47 | |
| 48 | def _add_task_to_trace(self, task, return_value): |
| 49 | """Add a task to the currently running task trace.""" |