The problem may be something to do with using "threading" as identifier name. It is name of a module and definitely what you want it done anyway. You are better off having another variable as counter (with a different name). Raghu.