新增锁

This commit is contained in:
shenjian@fangjia.com
2023-03-09 16:57:54 +08:00
parent 0466cd3772
commit 44597fd073
@@ -8,6 +8,10 @@ from elasticsearch import helpers
import numpy as np
from concurrent.futures import ThreadPoolExecutor
import sys
import threading
# 创建线程锁
lock = threading.Lock()
log = logging.getLogger(__name__)
es206_client = ElasticSearchClient(host='192.168.0.206')
@@ -83,6 +87,7 @@ def find_around_price_item(seaweed_df, index, item):
print(lat)
print(price)
print(index)
lock.acquire()
if pd.notna(price):
seaweed_df.loc[index, 'avg_cost'] = int(price)
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
@@ -90,6 +95,7 @@ def find_around_price_item(seaweed_df, index, item):
print(seaweed_df.loc[index])
else:
seaweed_df.loc[index, 'avg_cost'] = None
lock.release()
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
print(seaweed_df.loc[index])