У меня есть следующий код:
Код: Выделить всё
for i in range(len(json_data)):
print(i)
if int(json_data[i]['response']['result_count'])>0:
for j in range(len(json_data[i]['response']['matches'])):
try:
socket.gethostbyname(json_data[i]['response']['matches'][j]['domain'] )
except:
del json_data[i]['response']['matches'][j]['domain']
Код: Выделить всё
def run_half():
for i in range(0,round(len(data_json)/2)):
print(i) # make this len(data_json) if NOT testing, range(10) if testing
if int(data_json[i]['response']['result_count'])>0:
for j in range(len(data_json[i]['response']['matches'])):
try:
socket.gethostbyname( data_json[i]['response']['matches'][j]['domain'] )
except:
del data_json[i]['response']['matches'][j]['domain']
def run_half_2():
for i in range(round((len(data_json)/2))+1,len(data_json)):
print(i) # make this len(data_json) if NOT testing, range(10) if testing
if int(data_json[i]['response']['result_count'])>0:
for j in range(len(data_json[i]['response']['matches'])):
try:
socket.gethostbyname( data_json[i]['response']['matches'][j]['domain'] )
except:
del data_json[i]['response']['matches'][j]['domain']
t1 = threading.Thread(target=run_half(),args=(10,))
t2= threading.Thread(target=run_half_2(),args=(10,))
t1.start()
t2.start()
t1.join()
t2.join()
Будем очень признательны за любые советы и предложения. Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/721 ... seful-here
Мобильная версия