v1.0
This commit is contained in:
@@ -17,9 +17,7 @@ database_url = (
|
||||
)
|
||||
engine = create_async_engine(
|
||||
database_url,
|
||||
pool_size=20,
|
||||
max_overflow=10,
|
||||
pool_timeout=1000
|
||||
pool_timeout=2000
|
||||
)
|
||||
session_factory = async_sessionmaker(
|
||||
engine,
|
||||
|
||||
@@ -16,11 +16,13 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
|
||||
self.marketplace = marketplace
|
||||
auth_data = json.loads(marketplace.auth_data)
|
||||
token = auth_data.get('token')
|
||||
self.is_valid = True
|
||||
try:
|
||||
decoded_token = jwt.decode(token, algorithms=["HS256"], options={"verify_signature": False})
|
||||
except Exception:
|
||||
logging.error(f"Couldn't decode token for {marketplace.id}")
|
||||
return None
|
||||
self.is_valid = False
|
||||
return
|
||||
self.limiter_key = str(marketplace.company_id) + str(decoded_token.get('sid'))
|
||||
|
||||
self.headers = {
|
||||
@@ -38,6 +40,9 @@ class WildberriesMarketplaceApi(BaseMarketplaceApi):
|
||||
async def update_stocks(self, data: Union[list, dict]):
|
||||
if type(data) is not list:
|
||||
return
|
||||
if not self.is_valid:
|
||||
logging.warning(f'Skipping marketplace [{self.marketplace.id}] because of invalid token')
|
||||
return
|
||||
max_stocks = 1000
|
||||
chunks = utils.chunk_list(data, max_stocks)
|
||||
limiter = BatchLimiter()
|
||||
|
||||
Reference in New Issue
Block a user