def dump_stacks(cls, futures, verbose=False): """ Logs the stack frame for each of the given futures. The Future objects must have been submitted with ``_submit_execution`` so that they contain the necessary information. """ frames = dict(iter_thread_frames()) for i, future in enumerate(futures, 1): try: frame = frames[future.ctx['thread_ident']] except KeyError: frame = None # this might happen in race-conditions with a new thread starting if not verbose or not frame: if frame: frame_line = _find_interesting_frame(frame)[:3] location = " - %s:%s, in %s(..)" % tuple(frame_line) else: location = "..." _logger.info("%3s - %s (DARK_YELLOW<<%s>>)%s", i, future.funcname, cls._get_context(future), location) continue with _logger.indented("%3s - %s (%s)", i, future.funcname, cls._get_context(future), footer=False): lines = format_thread_stack(frame, skip_modules=[this_module ]).splitlines() for line in lines: _logger.info(line.strip())
def dump_stacks(self, futures=None, verbose=False): futures = futures or self frames = dict(iter_thread_frames()) for i, future in enumerate(futures, 1): try: frame = frames[future.ctx['thread_ident']] except KeyError: frame = None # this might happen in race-conditions with a new thread starting if not verbose or not frame: if frame: location = " - %s:%s, in %s(..)" % tuple(extract_stack(frame)[-1][:3]) else: location = "..." _logger.info("%3s - %s (DARK_YELLOW<<%s>>)%s", i, future.funcname, _get_context(future), location) continue with _logger.indented("%3s - %s (%s)", i, future.funcname, _get_context(future), footer=False): lines = format_thread_stack(frame, skip_modules=[this_module]).splitlines() for line in lines: _logger.info(line.strip())