473,246 Members | 1,389 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,246 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 4321
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.