recreate-fixed-4
This commit is contained in:
parent
c8acf6a9ac
commit
cb85e24a11
|
@ -54,6 +54,7 @@ class SearchService:
|
||||||
def __init__(self, index_name='search_index'):
|
def __init__(self, index_name='search_index'):
|
||||||
self.index_name = index_name
|
self.index_name = index_name
|
||||||
self.client = None
|
self.client = None
|
||||||
|
self.lock = asyncio.Lock() # Create an asyncio lock
|
||||||
|
|
||||||
# Only initialize the instance if it's not already initialized
|
# Only initialize the instance if it's not already initialized
|
||||||
if ELASTIC_HOST:
|
if ELASTIC_HOST:
|
||||||
|
@ -112,8 +113,8 @@ class SearchService:
|
||||||
await self.recreate_index()
|
await self.recreate_index()
|
||||||
|
|
||||||
async def recreate_index(self):
|
async def recreate_index(self):
|
||||||
async with asyncio.Lock():
|
async with self.lock:
|
||||||
self.delete_index()
|
self.client.indices.delete(index=self.index_name, ignore_unavailable=True)
|
||||||
await self.check_index()
|
await self.check_index()
|
||||||
|
|
||||||
def index(self, shout):
|
def index(self, shout):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user