From 6b2528bedf3e02f8431d3bff38485ab7fcebdf16 Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Thu, 18 Jul 2024 19:16:28 +0300 Subject: [PATCH] Fixes --- fast_bitrix24/bitrix.py | 5 +++-- fast_bitrix24/srh.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fast_bitrix24/bitrix.py b/fast_bitrix24/bitrix.py index b9b1de5..ee7ba46 100644 --- a/fast_bitrix24/bitrix.py +++ b/fast_bitrix24/bitrix.py @@ -3,7 +3,7 @@ import asyncio import functools as ft from contextlib import contextmanager -from typing import Iterable, Union +from typing import Iterable, Union, Awaitable import aiohttp import icontract @@ -25,10 +25,11 @@ class BitrixAsync: """Клиент для асинхронных запросов к Битрикс24.""" + @beartype def __init__( self, webhook: str, - token_func: callable = None, + token_func: Awaitable = None, verbose: bool = True, respect_velocity_policy: bool = True, request_pool_size: int = 50, diff --git a/fast_bitrix24/srh.py b/fast_bitrix24/srh.py index 3cfec90..9fe1a16 100644 --- a/fast_bitrix24/srh.py +++ b/fast_bitrix24/srh.py @@ -59,7 +59,7 @@ class ServerRequestHandler: def __init__( self, webhook: str, - token_func: callable, + token_func, respect_velocity_policy: bool, request_pool_size: int, requests_per_second: float, @@ -176,7 +176,7 @@ async def request_attempt(self, method, params=None) -> dict: async with self.acquire(method): logger.debug(f"Requesting {{'method': {method}, 'params': {params}}}") - params_with_auth = params.copy() + params_with_auth = params.copy() if params else {} if self.token_func: # если требуется авторизация @@ -318,5 +318,5 @@ async def update_token(self): """Запросить новый токен авторизации.""" self.token_request_in_progress.clear() - self.token = self.token_func + self.token = await self.token_func() self.token_request_in_progress.set()