refactor: simplify stock sending logic by processing chunks sequentially
This commit is contained in:
@@ -70,13 +70,16 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
|
||||
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:])
|
||||
for chunk in chunks:
|
||||
await send_stock_chunk(chunk)
|
||||
await asyncio.sleep(0.2)
|
||||
# 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()
|
||||
|
||||
Reference in New Issue
Block a user