scusami ma di ignoranza ne ho il cervello pieno, come si usa il loco ? come implementarlo nell'esempio che ho postato ?
ho provato con : > lock = Threading.Lock() ma nn mi e' cambiato nulla. #### import threading import urllib from tempfile import NamedTemporaryFile class download(threading.Thread): def __init__(self, sitecode, lista): threading.Thread.__init__(self) self.sitecode = sitecode self.status = -1 def run(self): url = 'http://waterdata.usgs.gov/nwis/monthly?referred_module=sw&site_no=' url += self.sitecode url += '&PARAmeter_cd=00060&partial_periods=on&format=rdb&submitted_form=parameter_selection_list' tmp = NamedTemporaryFile(delete=False) urllib.urlretrieve(url, tmp.name) print 'loaded Monthly data for sitecode : ', self.sitecode lista.append(tmp.name) print lista sitecodelist = ['01046500', '01018500', '01010500', '01034500', '01059000', '01066000', '01100000'] lista = [] for k in sitecodelist: get_data = download(k,lista) get_data.start() #### mi printa la lista .. ma non mi e' affatto chiaro come fare il "return" dell'oggetto 'lista'. Il giorno Dec 9, 2011, alle ore 3:41 PM, Daniele Maccio ha scritto: > Il 09 dicembre 2011 21:38, Massimo Di Stefano > <massimodisa...@gmail.com> ha scritto: >> e quello che sto provando a capire come si fa … :( >> > > lock = Threading.Lock() > > class MioThreadAntani....: > def MioMetodoConcorrenzialeEtc....: > ... > ... > # Area pericolosa accesso dati condivisi dai thread > with lock: > lista.append(path) > ... > ... > > Forse mi sto perdendo qualcosa, ma non basterebbe questo? > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python