新增锁
This commit is contained in:
@@ -8,6 +8,10 @@ from elasticsearch import helpers
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
|
|
||||||
|
# 创建线程锁
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
@@ -83,6 +87,7 @@ def find_around_price_item(seaweed_df, index, item):
|
|||||||
print(lat)
|
print(lat)
|
||||||
print(price)
|
print(price)
|
||||||
print(index)
|
print(index)
|
||||||
|
lock.acquire()
|
||||||
if pd.notna(price):
|
if pd.notna(price):
|
||||||
seaweed_df.loc[index, 'avg_cost'] = int(price)
|
seaweed_df.loc[index, 'avg_cost'] = int(price)
|
||||||
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
|
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
|
||||||
@@ -90,6 +95,7 @@ def find_around_price_item(seaweed_df, index, item):
|
|||||||
print(seaweed_df.loc[index])
|
print(seaweed_df.loc[index])
|
||||||
else:
|
else:
|
||||||
seaweed_df.loc[index, 'avg_cost'] = None
|
seaweed_df.loc[index, 'avg_cost'] = None
|
||||||
|
lock.release()
|
||||||
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
|
if item['_id'] == '50bd172ae4b0fbe60a6fe628':
|
||||||
print(seaweed_df.loc[index])
|
print(seaweed_df.loc[index])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user