Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 643913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:20:04+00:00 2026-05-13T21:20:04+00:00

How can we detect when threads are running in a python application? Motivation: We

  • 0

How can we detect when threads are running in a python application?

Motivation: We were recently debugging a large Python application that had several customer supplied modules that were supplied without source code. Unbeknowst to us (and our customer!), one of these modules would launch threads under very specific (and undocumented) conditions. These threads caused unexpected side effects which changed our environment in unexpected ways. The entire debugging scenario would be funny if it wasn’t my team stuck with the task of figuring out where the side effects were coming from 🙂

We finally discovered what was happening when one of the threads raised an un-trapped error. Had this not happened, we would still be pulling our hair out.

So, this is why we’re looking for a way to detect the presence of threads in our application.

Here are some possible techniques we came up with and the corresponding challenges:

  1. Grep source code for thread/threading. Challenge: We don’t always have access to source code. And even if we can find instances of thread creation in the source code, we still want a real-time technique for detecting when threads are currently active.

  2. Look for thread or threading in sys.modules. Challenge: Only insures these modules were loaded – doesn’t prove that threads are currently running.

  3. Monkey-patch the Python standard thread/threading library to leave us clues as to when threads have been created. Challenge: Only tells us whether threads have been created – does not provide any information about whether threads are currently running.

Thanks!
Malcolm

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:20:04+00:00Added an answer on May 13, 2026 at 9:20 pm

    Debugger

    Usually a debugger can show you all the threads and what each one is executing. If you tell us which debugger you are using, someone can tell you how to see the thread info. If you aren’t using a debugger, I highly suggest you start. Debugging multi-threaded programs without a real debugger is quite error-prone and inefficient. Personally, I use WingIDE.

    Runtime

    If you’re just poking around in the interpreter or trying to detect this situation in your code, perhaps sys._current_frames() might help. It returns the stack frame for each thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 450k
  • Answers 450k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For a long time Java offered no such method. Like… May 15, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer After working on it for a few hours I found… May 15, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer You need to adjust the mouse coordinates because they are… May 15, 2026 at 8:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.