Skip to content

Commit efab7d5

Browse files
committed
node: fix errorin using the timeout arg with newer versions of aiohttp
Signed-off-by: Claudio Usai <[email protected]>
1 parent 1ce2a5c commit efab7d5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

suzieq/poller/worker/nodes/node.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,15 +1338,15 @@ class EosNode(Node):
13381338
async def _rest_connect(self):
13391339
'''Check that connectivity and authentication works'''
13401340

1341-
timeout = self.cmd_timeout
1341+
timeout = aiohttp.ClientTimeout(self.cmd_timeout)
13421342

13431343
auth = aiohttp.BasicAuth(self.username,
13441344
password=self.password or 'vagrant')
13451345
url = f"https://{self.address}:{self.port}/command-api"
13461346

13471347
try:
13481348
self._conn = aiohttp.ClientSession(
1349-
auth=auth, timeout=self.connect_timeout,
1349+
auth=auth, timeout=timeout,
13501350
connector=aiohttp.TCPConnector(ssl=False))
13511351
async with self._conn.post(url, timeout=timeout) as response:
13521352
_ = response.status
@@ -1414,7 +1414,7 @@ async def _rest_gather(self, service_callback, cmd_list, cb_token,
14141414
await self._post_result(service_callback, result, cb_token)
14151415
return
14161416

1417-
timeout = timeout or self.cmd_timeout
1417+
timeout = aiohttp.ClientTimeout(timeout or self.cmd_timeout)
14181418

14191419
now = int(time.time() * 1000)
14201420
data = {
@@ -2154,8 +2154,8 @@ async def get_api_key(self):
21542154
if not self._retry:
21552155
return
21562156
async with self._cmd_pacer.wait(self.per_cmd_auth):
2157-
async with self._conn.get(url, timeout=self.connect_timeout) \
2158-
as response:
2157+
timeout = aiohttp.ClientTimeout(self.connect_timeout)
2158+
async with self._conn.get(url, timeout=timeout) as response:
21592159
status, xml = response.status, await response.text()
21602160
if status == 200:
21612161
data = xmltodict.parse(xml)
@@ -2215,9 +2215,10 @@ async def _rest_connect(self):
22152215
# In case of PANOS, getting here means REST is up
22162216
if not self._conn:
22172217
async with self._cmd_pacer.wait(self.per_cmd_auth):
2218+
timeout = aiohttp.ClientTimeout(self.connect_timeout)
22182219
try:
22192220
self._conn = aiohttp.ClientSession(
2220-
conn_timeout=self.connect_timeout,
2221+
conn_timeout=timeout,
22212222
connector=aiohttp.TCPConnector(ssl=False),
22222223
)
22232224
if self.api_key is None:
@@ -2240,7 +2241,7 @@ async def _rest_gather(self, service_callback, cmd_list, cb_token,
22402241
if not cmd_list:
22412242
return result
22422243

2243-
timeout = timeout or self.connect_timeout
2244+
timeout = aiohttp.ClientTimeout(timeout or self.connect_timeout)
22442245

22452246
url = f"https://{self.address}:{self.port}/api/"
22462247

0 commit comments

Comments
 (0)