This commit is contained in:
2024-07-06 05:47:11 +03:00
parent 2fac36f005
commit bc2fef91c4
4 changed files with 23 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
chunks = utils.chunk_list(data, max_stocks)
if not chunks:
return
self.init_session()
limiter = BatchLimiter()
async def send_stock_chunk(chunk):
@@ -67,11 +68,14 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
logging.error(
f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}')
return False
tasks = [send_stock_chunk(chunk) for chunk in chunks]
first_request = tasks[0]
first_response = await first_request
if not first_response:
logging.error(f'Skipping marketplace [{self.marketplace.id}] because first request was unsuccessful')
await self.session.close()
return
await asyncio.gather(*tasks[1:])
await self.session.close()