Commit d0a857c9 authored by 张彦钊's avatar 张彦钊

add notes for test

parent c6881729
...@@ -52,35 +52,35 @@ def pool_method(i,sql,allCitiesTop3000): ...@@ -52,35 +52,35 @@ def pool_method(i,sql,allCitiesTop3000):
# 把城市列表切分成n份,然后拼接成一个列表 # 把城市列表切分成n份,然后拼接成一个列表
def split_cityList(cityList,n): # def split_cityList(cityList,n):
l = len(cityList) # l = len(cityList)
step = np.rint(l/n) # step = np.rint(l/n)
new_list = [] # new_list = []
x = 0 # x = 0
while True: # while True:
if x + step < : # if x + step < :
data_list.append(data.iloc[x:x + step]) # data_list.append(data.iloc[x:x + step])
x = x + step + 1 # x = x + step + 1
else: # else:
data_list.append(data.iloc[x:data.__len__()]) # data_list.append(data.iloc[x:data.__len__()])
break # break
# 多线程方法获取全国城市热门日记 # 多线程方法获取全国城市热门日记
def multi_get_eachCityDiaryTop3000(processes): # def multi_get_eachCityDiaryTop3000(processes):
cityList = get_cityList() # cityList = get_cityList()
allCitiesTop3000 = get_allCitiesDiaryTop3000() # allCitiesTop3000 = get_allCitiesDiaryTop3000()
#
pool = Pool(processes) # pool = Pool(processes)
for i in range(len(data_list)): # for i in range(len(data_list)):
data_list[i] = pool.apply_async(self.pool_function, (data_list[i], t,)) # data_list[i] = pool.apply_async(self.pool_function, (data_list[i], t,))
#
result_map = {} # result_map = {}
for i in data_list: # for i in data_list:
result_map.update(i.get()) # result_map.update(i.get())
pool.close() # pool.close()
pool.join() # pool.join()
def get_eachCityDiaryTop3000(): def get_eachCityDiaryTop3000():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment