471,330 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Simple Threading Example Doesn't Work (2.5.1)

Hello,

I've tried to run several threading examples in Python 2.5.1 (with
Stackless) For example:

import threading

theVar = 1

class MyThread ( threading.Thread ):

def run ( self ):

global theVar
print 'This is thread ' + str ( theVar ) + ' speaking.'
print 'Hello and good bye.'
theVar = theVar + 1

for x in xrange ( 20 ):
MyThread().start()

It doesn't work. It says there's an error in Queue.py in:
self.mutex=threading.Lock()
AttributeError: 'module' object has no attribute Lock

The funny thing is that when I use the -O switch, it seems to work.
I'm baffled by this. What do you think is happening?

Thanks.

Jun 12 '07 #1
1 4004
In <11*********************@i38g2000prf.googlegroups. com>, Seun Osewa
wrote:
I've tried to run several threading examples in Python 2.5.1 (with
Stackless) For example:

import threading

theVar = 1

class MyThread ( threading.Thread ):

def run ( self ):

global theVar
print 'This is thread ' + str ( theVar ) + ' speaking.'
print 'Hello and good bye.'
theVar = theVar + 1

for x in xrange ( 20 ):
MyThread().start()

It doesn't work. It says there's an error in Queue.py in:
self.mutex=threading.Lock()
AttributeError: 'module' object has no attribute Lock

The funny thing is that when I use the -O switch, it seems to work.
I'm baffled by this. What do you think is happening?
Any chance that you have a module called `threading` that is not the one
in the standard library? Perhaps you named the script above `threading.py`!?

Ciao,
Marc 'BlackJack' Rintsch
Jun 12 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by J. Hall | last post: by
1 post views Thread by Nemo | last post: by
3 posts views Thread by Charles | last post: by
2 posts views Thread by usenet | last post: by
reply views Thread by Grzegorz Smith | last post: by
4 posts views Thread by Ramon F Herrera | last post: by
2 posts views Thread by Andy B | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.