@@ -62,7 +62,6 @@ def __init__(self, brand: str, websession: ClientSession) -> None:
62
62
self ._last_update = None
63
63
self ._websession = websession
64
64
self ._update_lock = asyncio .Lock ()
65
- self ._request_lock = asyncio .Lock ()
66
65
67
66
async def _request (
68
67
self ,
@@ -88,34 +87,33 @@ async def _request(
88
87
89
88
start_request_time = datetime .time (datetime .now ())
90
89
_LOGGER .debug ('%s Initiating request to %s' , start_request_time , url )
91
- async with self ._request_lock :
92
- timeout = DEFAULT_TIMEOUT
93
- # Repeat twice amount of max requests retries for timeout errors.
94
- for attempt in range (0 , (DEFAULT_REQUEST_RETRIES * 2 ) - 1 ):
95
- try :
96
- async with self ._websession .request (
97
- method , url , headers = headers , params = params ,
98
- data = data , json = json , timeout = timeout ,
99
- ** kwargs ) as resp :
100
- resp .raise_for_status ()
101
- return await resp .json (content_type = None )
102
- except asyncio .TimeoutError :
103
- timeout = timeout * 2
104
- _LOGGER .warning ('%s Timeout requesting from %s' ,
105
- start_request_time , endpoint )
106
- except ClientError as err :
107
- if attempt == DEFAULT_REQUEST_RETRIES - 1 :
108
- raise RequestError ('{} Client Error while requesting '
109
- 'data from {}: {}' .format (
110
- start_request_time , endpoint ,
111
- err ))
112
-
113
- _LOGGER .warning ('%s Error requesting from %s; retrying: '
114
- '%s' , start_request_time , endpoint , err )
115
- await asyncio .sleep (5 )
116
-
117
- raise RequestError ('{} Constant timeouts while requesting data '
118
- 'from {}' .format (start_request_time , endpoint ))
90
+ timeout = DEFAULT_TIMEOUT
91
+ # Repeat twice amount of max requests retries for timeout errors.
92
+ for attempt in range (0 , (DEFAULT_REQUEST_RETRIES * 2 ) - 1 ):
93
+ try :
94
+ async with self ._websession .request (
95
+ method , url , headers = headers , params = params ,
96
+ data = data , json = json , timeout = timeout ,
97
+ ** kwargs ) as resp :
98
+ resp .raise_for_status ()
99
+ return await resp .json (content_type = None )
100
+ except asyncio .TimeoutError :
101
+ timeout = timeout * 2
102
+ _LOGGER .warning ('%s Timeout requesting from %s' ,
103
+ start_request_time , endpoint )
104
+ except ClientError as err :
105
+ if attempt == DEFAULT_REQUEST_RETRIES - 1 :
106
+ raise RequestError ('{} Client Error while requesting '
107
+ 'data from {}: {}' .format (
108
+ start_request_time , endpoint ,
109
+ err ))
110
+
111
+ _LOGGER .warning ('%s Error requesting from %s; retrying: '
112
+ '%s' , start_request_time , endpoint , err )
113
+ await asyncio .sleep (5 )
114
+
115
+ raise RequestError ('{} Constant timeouts while requesting data '
116
+ 'from {}' .format (start_request_time , endpoint ))
119
117
120
118
async def _update_device_state (self ) -> None :
121
119
async with self ._update_lock :
0 commit comments