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