(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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -