interesting threading result..

Alan Franzoni alan.franzoni_invalid at geemail.invalid
Mon Oct 29 17:29:10 EDT 2007


Il Mon, 29 Oct 2007 09:08:01 -0700, Abandoned ha scritto:

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

You must have messed up with something. You didn't post a working snippet
in first place, so you should do it now. I suppose you're working with some
editor or IDE which mantains the very same instance of a python interpreter
in memory; you probably have done something like 

end.append(current)

at a certain point in your tests.

I converted your pseudocode to python like that:

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}

nlist = []
current = GetData("a")
nlist.append(current)
current.start()
end=[]
dd=nlist[0]
dd.join()
result=dd.data
print result
end.append(result)
print end

and I just get the result I would expect:

{2: 3, 3: 4}
[{2: 3, 3: 4}]


-- 
Alan Franzoni <alan.franzoni.xyz at gmail.com>
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 



More information about the Python-list mailing list