473,387 Members | 1,693 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,387 software developers and data experts.

basic thread, big problem (logic? - probably)

I'm quite new to code with thread. I found that it is useful for graphical
programming, but now I would like to add this to some of my program.

I tried something but I think I'll have to read a little more on it.
What my program do, is to query a microsoft AD to find all servers in it, then
it query all of those servers for some information on their registry keys. In
fact, everything work well, but the whole process take more than 30 minutes.
Most of the waiting is cause by the "waiting for time out" when server are
not responding.

So what I try to do, is to start two threads at a time, then if one get
busy, the other one can continue with other query. But my code somehow failed,
it is faster, but one save minute on 30, it clearly demonstrate that my
code is wrong.

here is the section of the my "thread starter" :
# ## this start the request and set value in the array - this is the code to be threaded
def start_thread2(servername):
keyinfo = getregkey.getregkey(servername,"Software\Microsoft \DataAccess")
mdac_info.append([servername, keyinfo.GetKey("FullInstallVer")])
keyinfo.CloseKey
# free one thread after completion
thread_info["num_left"] = thread_info["num_left"] + 1

# the "threader"
# serverlist is the actual list of servers that come from the active directory query(LDAP)
# serverlistlen is the __len__() of this list
def start_thread(serverlist, serverlistlen):
while serverlistlen > 0: # while there's server to query
# if there's thread available for processing
if thread_info["num_left"] > 0 and thread_info["num_left"] <= thread_info["max"]:
try:
for i in range(thread_info["num_left"]): # how many thread are available to launch
thread.start_new(start_thread2, (serverlist[serverlistlen-1],))
serverlist.remove(serverlist[serverlistlen-1])
serverlistlen = serverlistlen - 1 # remove one possible thread
thread_info["num_left"] = thread_info["num_left"] - 1
except:
pass # if only one server left, but two threads are availlable, it will raise an exception.
else:
pass # loop
# --

the probleme is that the loop get stuck often, like the two threads were use and waiting (to many time than possible), but even so it should loop an take the 'else' path, but it does not.

If my logic is totally wrong, I would appreciate to have a word on a good book/tutorial/guide available to code with thread in python.

Thank you
Francis
Jul 18 '05 #1
0 990

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

Similar topics

2
by: Matt | last post by:
I know we can write ASP with VB Script. Some people told me the big ASP projects usually use Visual Basic for the business logic. Is that the case? What I mean is an ASP project is the combination...
31
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
3
by: KC | last post by:
Hey, I'm trying to implement a cancel button in my app (this is after the bulk of the program has been built). To do this I, of course, need to use a thread to run the time consuming method...
4
by: Russell Warren | last post by:
I'm guessing no, since it skips down through any Lock semantics, but I'm wondering what the best way to clear a Queue is then. Esentially I want to do a "get all" and ignore what pops out, but I...
2
by: tshad | last post by:
I have a Service that starts a thread that never ends. When I stop the service from the Service Applet, does it kill the thread or do I need to do it myself? If it isn't killed, what happens...
5
by: salberts | last post by:
Hi, I am writing an application that has its UI and Logic layers. My initial idea was to launch the two layers on two different threads and manage calls made by the UI to the Logic manually....
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
3
by: JJ | last post by:
I've done a little multi-threading on winform apps some time ago now, so I'm not a complete beginner, but best assume I am for any explanations..: This is an asp.net 2.0 website, using c#: I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.