-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadparse.py
67 lines (55 loc) · 1.84 KB
/
threadparse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import revhelper
import os.path
import urllib
import imgchar
import traf
import revs
import shutil
import threading
import time
starttime = time.time()
infile = open("lookup.tmp")
names = []
for line in infile:
names.append(line.strip())
def timgchar(playername, month, year):
"""thread worker function"""
print 'Imgchar: %s' % playername + " at " + str(time.clock())
imgchar.updateimgcharlookup(playername,month,year)
return
def ttraf(playername, month, year):
"""thread worker function"""
print 'Traf: %s' % playername + " at " + str(time.clock())
traf.updatetraflookup(playername, month, year)
return
def trevs(playername, month, year):
"""thread worker function"""
print 'Revs: %s' % playername + " at " + str(time.clock())
revs.updaterevslookup(playername, month, year)
return
threads = []
count = 0
for name in names:
count = count + 1
for month in range(12,13):
for year in range(2011,2012):
# for each combination get revid information and update lookup
playername = urllib.quote(name)
print
print "Getting " + playername + ":" + str(month) +"," + str(year)
t1 = threading.Thread(target=timgchar, args=(playername,month, year,))
threads.append(t1)
t1.start()
t2 = threading.Thread(target=ttraf, args=(playername,month, year,))
threads.append(t2)
t2.start()
t3 = threading.Thread(target=trevs, args=(playername,month, year,))
threads.append(t3)
t3.start()
print
if count % 3 == 0:
print "waiting for threads \n"
for thread in threading.enumerate():
if thread is not threading.currentThread():
thread.join()
print "elapsed time " + str(time.time() - starttime)