Python Forum
Thread Rating:
  • 4 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
threading.active_count()
#1
Does the threading.active..... catch threads started with 'thread' as well as 'threading'?

My app is setting off loads of threads, all the same def, but the above is only ever reporting 1, which I assume is the main thread.

I'm trying to track the reason for an error:

--can't start new thread.
or
--thread.close failed in file object destructor:
or
--lost sys.stderr

Anyone have any ideas?
Thanks.
Reply
#2
The documentation says that is returns the number of alive threading.Thread instances. I think it is clear enough: other threads are not counted.
Reply
#3
Solved with a simple 'return' at the end of the def being threaded.

I haven't seen a threading example anywhere yet that says you should always 'return' even if there is no return value.

But, now I know. I hope this might be of some use to others.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,922 May-03-2023, 08:22 AM
Last Post: billykid999
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,148 Oct-01-2021, 08:32 PM
Last Post: muzikman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020