473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 4340
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: red | last post by:
within an object function, this code: $test2='test'; echo "$test"; $this->test2='test2'; echo "$this->test2\n"; produces this result: test2
7
by: J. Hall | last post by:
Hi dudes, Got a simple webpage, with three numeric text input boxes, the idea being that the user is asked to insert percentages of their business around the world... UK, Europe, Other ...
1
by: Nemo | last post by:
Hi, I've a web service working ok in POST request but when I try to invoke it by the browser url, in GET format, the server throw a error "Request Format not Known" I try invoke this simple WS...
3
by: Charles | last post by:
I am trying the example of the book "Learning PHP5", here's an example that doesn't work here. It's a simple array sent from a form, and I want to display values sent, but if I select several meals...
2
by: usenet | last post by:
Hi, I have a simple php script which takes a variable from the url and prints it out. I've recently changed linux cpanel/whm severs and it no longer runs. What modules do I need to install/how...
0
by: Grzegorz Smith | last post by:
Hi All. I 'm learning ZSI to use SOAP and I desperately need help. I'm working on example from tutorial -(examples/server/send_response/ simple/wsdl/). Here are my wsdl files...
4
by: Ramon F Herrera | last post by:
I am running the examples included in the book "Thinking in C++" (*). This one has a a problem: //: C02:Scopy.cpp // Copy one file to another, a line at a time #include <string> #include...
1
by: Curious | last post by:
Hi, In my code, I observe an event. In the event handler, I have: if (mIsMarketOpen == false) { // Execute "CheckHistoricalData" every 15 seconds System.Threading.Timer timer = new...
2
by: Andy B | last post by:
I have a wizardStep with 2 textBoxes and a button on it. The textBoxes are called WordTextBox and DefinitionTextBox. In the button_click event, I added this code: AddDefinition(); The code...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.