threading module

Al-Amerrho H. Amerin al_amerin at yahoo.com
Mon Jun 26 23:58:21 EDT 2000


I was using the threading module's activeCount() method when I noticed
that when you import it, it spawns a thread, MainThread. And this
becomes
a problem when I call threading.activeCount(). It returns the number of
threads I spawned + 1.

Python 1.6a2 (#9, Jun 22 2000, 00:09:08)  [GCC 2.95.2 19991024
(release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)

>>> import threading
>>> threading.activeCount()
1
>>>

I hope someone can enlighten me as to the reason why activeCount()
includes the MainThread and
why this shouldn't be fixed so activeCount() will only return the number
of threads that a caller spawns.



Al-Amerrho Amerin





More information about the Python-list mailing list