Lists the active threads and their current code line
518094
def threads_list():
        
        results = {}

        # pylint: disable=W0212
        try:
            # Extract frames
            frames = sys._current_frames()

            # Get the thread ID -> Thread mapping
            names = threading._active.copy()
        except AttributeError:
            # Extraction not available
            return results

        # Sort by thread ID
        thread_ids = sorted(frames.keys())
        for thread_id in thread_ids:
            # Get the corresponding stack
            stack = frames[thread_id]

            # Try to get the thread name
            try:
                name = names[thread_id].name
            except KeyError:
                name = "<unknown>"

            trace_lines = []
            frame = stack
            while frame is not None:
                # Store the line information
                trace_lines.append(format_frame_info(frame))

                # Previous frame...
                frame = frame.f_back

            # Construct the thread description
            results[thread_id] = {
                "name": name,
                "stacktrace": "\n".join(reversed(trace_lines)),
            }

        return results
855172
def list_actions():
    """"""
    for name, action in _current_actions.items():
        click.echo('{0}:{1}'.format(
            name, '*' if hasattr(action, 'argument') else ''
        ))
131569
def threadProfileCode(func, *args, **kwargs):
    ''
    with ThreadProfiler(threading.current_thread()) as prof:
        try:
            prof.thread.status = threadProfileCode.__wrapped__(func, *args, **kwargs)
        except EscapeException as e:
            prof.thread.status = e
801270
def ThreadsWithRunningExecServers(self):
    """"""
    socket_dir = '/tmp/pyringe_%s' % self.inferior.pid
    if os.path.isdir(socket_dir):
      return [int(fname[:-9])
              for fname in os.listdir(socket_dir)
              if fname.endswith('.execsock')]
    return []
798970
def get_active_tasks(self):
        """"""
        current_tasks = self.celery.control.inspect().active() or dict()
        return [
            task.get('id') for host in current_tasks.values() for task in host]
1306021
def on_threads_request(self, py_db, request):
        '''
        
        '''
        return self.api.list_threads(py_db, request.seq)
949033
def dump_threads(stream=None):
    '''
    
    '''
    if stream is None:
        stream = sys.stderr
    thread_id_to_name = {}
    try:
        for t in threading.enumerate():
            thread_id_to_name[t.ident] = '%s  (daemon: %s, pydevd thread: %s)' % (
                t.name, t.daemon, getattr(t, 'is_pydev_daemon_thread', False))
    except:
        pass

    from _pydevd_bundle.pydevd_additional_thread_info_regular import _current_frames

    stream.write('===============================================================================\n')
    stream.write('Threads running\n')
    stream.write('================================= Thread Dump =================================\n')
    stream.flush()

    for thread_id, stack in _current_frames().items():
        stream.write('\n-------------------------------------------------------------------------------\n')
        stream.write(" Thread %s" % thread_id_to_name.get(thread_id, thread_id))
        stream.write('\n\n')

        for i, (filename, lineno, name, line) in enumerate(traceback.extract_stack(stack)):

            stream.write(' File "%s", line %d, in %s\n' % (filename, lineno, name))
            if line:
                stream.write("   %s\n" % (line.strip()))

            if i == 0 and 'self' in stack.f_locals:
                stream.write('   self: ')
                try:
                    stream.write(str(stack.f_locals['self']))
                except:
                    stream.write('Unable to get str of: %s' % (type(stack.f_locals['self']),))
                stream.write('\n')
        stream.flush()

    stream.write('\n=============================== END Thread Dump ===============================')
    stream.flush()
1019587
private void collectThreadStats(final StatsCollector collector) {
    final Set<Thread> threads = Thread.getAllStackTraces().keySet();
    final Map<String, Integer> states = new HashMap<String, Integer>(6);
    states.put("new", 0);
    states.put("runnable", 0);
    states.put("blocked", 0);
    states.put("waiting", 0);
    states.put("timed_waiting", 0);
    states.put("terminated", 0);
    for (final Thread thread : threads) {
      int state_count = states.get(thread.getState().toString().toLowerCase());
      state_count++;
      states.put(thread.getState().toString().toLowerCase(), state_count);
    }
    for (final Map.Entry<String, Integer> entry : states.entrySet()) {
      collector.record("jvm.thread.states", entry.getValue(), "state=" + 
          entry.getKey());
    }
    collector.record("jvm.thread.count", threads.size());
  }
815971
public void checkAllThreads() {

        // if nothing is plugged in, exit early
        if (this.monitorPlugin == null) {
            return;
        }

        long currentTime = 0; // lazily initialize current time

        try {
            for (Iterator i = this.threads_.values().iterator(); i.hasNext();) {

                Worker thread = (Worker) i.next();
                synchronized (thread) { // d204471
                    if (thread.getStartTime() > 0) {
                        if (currentTime == 0) {
                            currentTime = System.currentTimeMillis();
                        }

                        if (!thread.isHung && this.monitorPlugin.checkThread(thread, thread.threadNumber, currentTime - thread.getStartTime())) { // PK25446
                            thread.isHung = true;
                        }
                    }
                }
            }

            this.lastThreadCheckDidntComplete = false; // D222794
        } catch (ConcurrentModificationException e) { // begin D222794
            // NOTE: we can pretty much ignore this exception ... if
            // we occasionally fail on the check, we'll be OK. So
            // we simply keep track with a flag. If two consecutive
            // checks fail, then we'll log to FFDC
            if (this.lastThreadCheckDidntComplete) {
                // Alex Ffdc.log(e, this, this.getClass().getName(), "1181", this); //
                // D477704.2
            }
            this.lastThreadCheckDidntComplete = true;
        } // end D222794
    }
1314670
public ArrayList getThreads()
  {
    if (tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getThreads");
      SibTr.exit(tc, "getThreads", _threadCache);
    }
    return _threadCache;
  }
1227090
def get_thread_hardware_breakpoints(self, dwThreadId):
        
        result = list()
        for (tid, bplist) in compat.iteritems(self.__hardwareBP):
            if tid == dwThreadId:
                for bp in bplist:
                    result.append(bp)
        return result
739969
def output_lines(self):
        
        if self.exception:
            return [self.EXCEPTION_HEADERS[0], '  ...'] + self.exception_detail
        else:
            return self.output
481435
private static <T> ThreadContext<T> getCurrentThreadContext(ThreadContext<T> threadContext)
    {
        return ((ThreadContextImpl<T>) threadContext).get();
    }
1289139
private void listActiveTrackers() throws IOException {
    ClusterStatus c = jobSubmitClient.getClusterStatus(true);
    Collection<String> trackers = c.getActiveTrackerNames();
    for (String trackerName : trackers) {
      System.out.println(trackerName);
    }
  }
957949
def get_current_thread_id(thread):
    '''
    
    '''
    try:
        # Fast path without getting lock.
        tid = thread.__pydevd_id__
        if tid is None:
            # Fix for https://www.brainwy.com/tracker/PyDev/645
            # if __pydevd_id__ is None, recalculate it... also, use an heuristic
            # that gives us always the same id for the thread (using thread.ident or id(thread)).
            raise AttributeError()
    except AttributeError:
        tid = _get_or_compute_thread_id_with_lock(thread, is_current_thread=True)

    return tid
1282456
public void list(String line, DispatchCallback callback) {
    int index = 0;
    DatabaseConnections databaseConnections = sqlLine.getDatabaseConnections();
    sqlLine.info(
        sqlLine.loc("active-connections", databaseConnections.size()));

    for (DatabaseConnection databaseConnection : databaseConnections) {
      boolean closed;
      try {
        closed = databaseConnection.connection.isClosed();
      } catch (Exception e) {
        closed = true;
      }

      sqlLine.output(
          sqlLine.getColorBuffer()
              .pad(" #" + index++ + "", 5)
              .pad(closed ? sqlLine.loc("closed") : sqlLine.loc("open"), 9)
              .pad(databaseConnection.getNickname(), 20)
              .append(" " + databaseConnection.getUrl()));
    }

    callback.setToSuccess();
  }
528155
private Thread[] enumerateThreads() {
        boolean fits = false;
        int inc = 50;
        Thread[] threads = null;
        int nrThreads = 0;
        while (!fits) {
            try {
                threads = new Thread[Thread.activeCount()+inc];
                nrThreads = Thread.enumerate(threads);
                fits = true;
            } catch (ArrayIndexOutOfBoundsException exp) {
                inc += 50;
            }
        }
        // Trim array
        Thread ret[] = new Thread[nrThreads];
        System.arraycopy(threads,0,ret,0,nrThreads);
        return ret;
    }