This commit is contained in:
2024-07-06 04:28:36 +03:00
parent cb3a02bb89
commit 24df5aaacd
3 changed files with 12 additions and 0 deletions

View File

@@ -45,6 +45,8 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
limiter = BatchLimiter()
async def send_stock_chunk(chunk):
if not self.is_valid:
return
try:
await limiter.acquire_ozon(self.limiter_key)
request_data = {'stocks': chunk}
@@ -55,9 +57,11 @@ class OzonMarketplaceApi(BaseMarketplaceApi):
if error_message:
logging.warning(
f'Error occurred when sending stocks to [{self.marketplace.id}]: {error_message} ({error_code})')
self.is_valid = False
except Exception as e:
logging.error(
f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}')
self.is_valid = False
tasks = [send_stock_chunk(chunk) for chunk in chunks]
await asyncio.gather(*tasks)