加锁
This commit is contained in:
@@ -7,6 +7,7 @@ from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, date
|
||||
from elasticsearch import helpers
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import sys
|
||||
from threading import Lock
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
@@ -15,6 +16,7 @@ es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||
index_name = "community_summary"
|
||||
path = "/home/airflow/data/community"
|
||||
m_date = dateutils.iso_format()
|
||||
mutex = Lock()
|
||||
|
||||
|
||||
def build_doc(item):
|
||||
@@ -51,11 +53,14 @@ def sync(city=None):
|
||||
|
||||
# 近三个月挂牌量
|
||||
sample_num = commutils.get_sample(curr_city, curr_region, names_str, cat='sell', daysBefore=93)
|
||||
seaweed_df.loc[index, 'three_months_sell_num'] = sample_num
|
||||
|
||||
# 近半年挂牌量
|
||||
sample_num = commutils.get_sample(curr_city, curr_region, names_str, cat='sell', daysBefore=186)
|
||||
seaweed_df.loc[index, 'half_on_year_sell_num'] = sample_num
|
||||
sample_half_year_num = commutils.get_sample(curr_city, curr_region, names_str, cat='sell', daysBefore=186)
|
||||
|
||||
mutex.acquire()
|
||||
seaweed_df.loc[index, 'three_months_sell_num'] = sample_num
|
||||
seaweed_df.loc[index, 'half_on_year_sell_num'] = sample_half_year_num
|
||||
mutex.release()
|
||||
|
||||
for index, item in seaweed_df.iterrows():
|
||||
pool.submit(deal, index, item)
|
||||
|
||||
Reference in New Issue
Block a user