473,324 Members | 2,456 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,324 software developers and data experts.

Testing threading

How one goes on testing a threaded program, apart from doing a few
successful runs and crossing his fingers that it at least follows the
'correct 99.9999% of the time' rule ? I've written a stripped-down
python version of Doug Lea's PooledExecutor thread pool class
(http://gee.cs.oswego.edu/dl/classes/...Executor.html),
I ran a few simple examples that seem to work as expected, but I still
wouldn't bet any serious amount on its correctness. Any general, or
specific to this problem, tesing guidelines ?

As for the 'stripped-down version', it refers to the lack of shutting
down facilities. These are based on interrupting a thread and AFAIK
this is not possible in python, is it ?

On the other hand, in addition to the main execute(command) method of
the original PooledExecutor, I added a new dispatch(callables)
generator method. This takes an iterable over zero-argument callables,
it dispatches them to separate threads according to the thread pool's
configuration (minPoolSize,maxPoolSize,etc.), collects the results in a
queue as they are computed and yields them back to the caller. Since
the order of the computed results is not in general the same with the
order of the input, the yielded items are tuples (i,result), where i is
the index of the respective callable that returned this result. As a
toy example:

from math import sqrt
from itertools import count
tasks = (lambda x=n: sqrt(x) for n in count())
pool = PooledExecutor(minPoolSize=4)
for n,s in pool.dispatch(tasks):
print "The square root of %d is %s" % (n,s)
George

Jul 18 '05 #1
0 1192

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
0
by: calfdog | last post by:
I am pleased to announce version cPAMIE 1.6 the Web automation tool for Internet explorer. If your looking for a fast way, easy to learn way to drive your browser check out PAMIE. Is PAMIE...
13
by: guy | last post by:
Hi, I'm running a batch test using a C# program. This often takes several hours to run and iterates over a bunch of parameters (say) 1000 times. The processor is maxed out during this time. ...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.