Simple Threading Example Doesn't Work (2.5.1)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Seun Osewa

    #1

    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.Threa d ):

    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().star t()

    It doesn't work. It says there's an error in Queue.py in:
    self.mutex=thre ading.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.

  • Marc 'BlackJack' Rintsch

    #2
    Re: Simple Threading Example Doesn't Work (2.5.1)

    In <1181676230.968 353.63280@i38g2 000prf.googlegr oups.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.Threa d ):
    >
    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().star t()
    >
    It doesn't work. It says there's an error in Queue.py in:
    self.mutex=thre ading.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

    Comment

    Working...