(python) using threads to get last value of stock market -


i'm trying last value of symbol list yahoo finance using thread in python. read thread documentary don't understand concept

#!/usr/bin/python  threading import thread  import urllib  import re    def th(ur):  	base = 'https://finance.yahoo.com/q?s='+ur  	htmlfile = urllib.urlopen(base).read()  	regex = '<span id="yfs_l84_[^.]*">(.+?)</span>'  	result = re.findall(regex,htmlfile)  	print result[0]    symbollist = open("symbollist.txt").read().splitlines()  threadlist = []  u in symbollist:  	t = thread(target=th,args=(u,))  	t.start()  	threadlist.append(t)  b in threadlist:  	b.join()
have symbol list contain 3000 symbol don't know how many thread should use or should lock threads

all code in function called "th" need thread safe.

if of isn't, you'll need lock around parts stop "threading" issues, example race conditions.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -