473,511 Members | 15,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

interesting threading result..

Hi..
I have a interesting threading result..

class GetData(threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
self.name = name

def run(self):
self.data={2:3, 3:4...}

current = GetData(a)
nlist.append(current)
current.start()
end=[]
dd=nlist[0]
dd.join()
result=dd.data
print result
(and it gives me : {2:3, 3:4...} )
end.append(result)
print end
(and it gives me: [<GetData(Thread-3, stopped)>, {2:3, 3:4...}] )
What happen ??
What is the <GetData(Thread-3, stopped)>, ?
In the first print there isn't it but second print it is in there.
I don't want <GetData(Thread-3, stopped)>..
How can i escape from it ?

I'm sorry my bad english.
King regards..

Oct 29 '07 #1
1 1009
En Mon, 29 Oct 2007 20:26:40 -0300, Abandoned <be*****@gmail.comescribió:
Now this is my real code and the problem continue.
What is the mistake?
I don't see where you define "query" so this can't be your complete code.
>
import threading
class GetData(threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
self.name = name
def run(self):
self.data={2:3, 3:4}
i=0
datas={"n": [['msn']]}
nglist=nlist={0: list()}
Here, you make nglist and nlist refer to the same object (a dictionary,
not a list!)
To be short: nglist and nlist are the same thing
for x in query:
tip=x
for a in datas[x]:
for o in a:
if len(o)>1:
current = GetData(o)
nglist[i].append(current)
current.start()
Here, you append current to nglist[i]. current is an instance of the
GetData class, a Thread. As nglist is the same thing as nlist, nlist[i]
contains a GetData instance too.
i=i+1

for x in range(0,len(nglist)):
for jk in range(0,len(nglist[x])):
jkl=nglist[x][jk]
jkl.join()
sonuc=jkl.data
nlist[x].append(sonuc)

print nlist
{0: [<GetData(Thread-1, stopped)>, {2: 3, 3: 4}]}
It's not surprising to see here the object appended above.

I can't say how to improve/fix this because I can't see the purpose of all
this. Could you explain what do you want to do exactly?

--
Gabriel Genellina

Oct 30 '07 #2

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

Similar topics

4
4881
by: Joe Wong | last post by:
Hi, Is there any way to increase/decrease a thread priority in Python? Best regards, -- Wong
1
1571
by: | last post by:
I want to get results from a thread from the main thread. In C I would use pthread_join to wait for the thread and access the result in a paramter I passed to pthread_join. In python I can wait...
5
4158
by: Francois De Serres | last post by:
Hiho, could somebody please enlighten me about the mechanics of C callbacks to Python? My domain is more specifically callbacks from the win32 API, but I'm not sure that's where the problem...
11
1809
by: Mark Rae | last post by:
Hi, My R&D department has asked me to look at threading in a Web Service written in C#, so I came up with the following code: using System; using System.ComponentModel; using...
13
371
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
3
4489
by: Asad | last post by:
Hi, I am trying to write some threading code to my application. The reason I've been tempted to do this is because, I am doing some FTP uploads, and sometimes during the put method, the...
2
4874
by: NiponW | last post by:
Hi, I have SQL SERVER 2000 SP4 Enterprise , Windows 2003 Enterprise on Xeon 4 Processors (now with multi-threading CPU) and I have questions which seem weirds to me (used to have the same...
3
1600
by: Shafik | last post by:
Hello folks, I'm having an issue with mixing wxPython and threading ... I realize multi-threading always introduces subtle bugs, but the following scenario is just odd: I start a dummy...
14
3421
by: Akihiro KAYAMA | last post by:
Hi all. I found cooperative multi-threading(only one thread runs at once, explicit thread switching) is useful for writing some simulators. With it, I'm able to be free from annoying mutual...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.