Counting Threads

David Poundall david at
Thu Oct 27 22:01:43 CEST 2005

>> But the count isn't doint what I expected.  I was after a increment
>> after every time the class was used ireespective of instance.

>I have no idea what that last sentence above means...

On re-reading it - neither do I.  Sorry about that.  What I meant to
say was that I was after an increment in the count variable (the class
attribute) not an increment only within the class instances.  Because
the variable was being set to zero every time the class was
instantiated I wasn't getting the true usage count.

> ServerThreads.GlobalThreadCount = 0

That was what the syntax I was missing.

> You appear to know there is a difference in spelling between these two
> "demons"... but only "daemon" is correct.  "Deamon" is a misspelling.

That one certainly slipped under the radar.

>You would want to wrap it with a threading.Lock() to
> protect it in that case.

Will do.

> But, again, using a global at all is wrong anyway

I posted using this sytax as it was nearly working - but I knew there
was a serious clanger in the code and you pointed it out when you
identified it was the class attribute syntax I was after.

Peter, thank you for taking the time to unpick my code.  It's much
apreciated.  I have only been coding with Python for the past couple of
weeks and switching my brain to work with Python classes has been a bit
of a challenge.  I wil re-read the document section on style tips
before I get too far into my app, as I would really like to be able to
code in a Pythonesque fashion.


More information about the Python-list mailing list