refactor: simplify stock sending logic by processing chunks sequentially

This commit is contained in:
2025-04-30 14:11:18 +03:00
parent 0ccd27252a
commit 0332e1c692

View File

@@ -70,13 +70,16 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}') f'Exception occurred while sending stocks to marketplace ID [{self.marketplace.id}]: {str(e)}')
return False return False
tasks = [send_stock_chunk(chunk) for chunk in chunks] for chunk in chunks:
first_request = tasks[0] await send_stock_chunk(chunk)
first_response = await first_request await asyncio.sleep(0.2)
if not first_response: # tasks = [send_stock_chunk(chunk) for chunk in chunks]
logging.error(f'Skipping marketplace [{self.marketplace.id}] because first request was unsuccessful') # first_request = tasks[0]
await self.session.close() # first_response = await first_request
return # if not first_response:
# logging.error(f'Skipping marketplace [{self.marketplace.id}] because first request was unsuccessful')
await asyncio.gather(*tasks[1:]) # await self.session.close()
# return
#
# await asyncio.gather(*tasks[1:])
await self.session.close() await self.session.close()