加锁
This commit is contained in:
@@ -7,12 +7,14 @@ import logging
|
||||
import sys
|
||||
from elasticsearch import helpers
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from threading import Lock
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||
index_name = "community_summary"
|
||||
|
||||
mutex = Lock()
|
||||
|
||||
def save(community_summary_df):
|
||||
if 'estate_charge' not in community_summary_df.columns:
|
||||
@@ -127,7 +129,9 @@ def sync_by_city(city_now):
|
||||
# 取周边均值
|
||||
estate_charge = docs['estate_charge'].mean()
|
||||
if pd.notna(estate_charge):
|
||||
mutex.acquire(timeout=60)
|
||||
community_summary_df.loc[index, "estate_charge"] = estate_charge
|
||||
mutex.release()
|
||||
for index, item in community_summary_df.iterrows():
|
||||
pool.submit(deal, index, item)
|
||||
save(community_summary_df)
|
||||
|
||||
Reference in New Issue
Block a user