472,954 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

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 999
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
by: Joe Wong | last post by:
Hi, Is there any way to increase/decrease a thread priority in Python? Best regards, -- Wong
1
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
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
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
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
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
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
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
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.