Skip to content

Commit b638ba0

Browse files
authored
Merge pull request #47 from mweinelt/native-asyncio-timeout
Use native asyncio.timeout from python stdlib
2 parents 39f585c + 1638356 commit b638ba0

9 files changed

Lines changed: 37 additions & 39 deletions

File tree

docs/account.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
102102
}
103103
if self.session is None:
104104
async with aiohttp.ClientSession() as session:
105-
async with async_timeout.timeout(10):
105+
async with asyncio.timeout(10):
106106
async with session.post(
107107
AUTHENTICATION_ENDPOINT, json=dataDictionary
108108
) as resp:
109109
await checkResponseForError(await resp.text())
110110
return await resp.text()
111111
else:
112-
async with async_timeout.timeout(10):
112+
async with asyncio.timeout(10):
113113
async with self.session.post(
114114
AUTHENTICATION_ENDPOINT, json=dataDictionary
115115
) as resp:
@@ -132,12 +132,12 @@ <h2 class="section-title" id="header-classes">Classes</h2>
132132
raise
133133
if self.session is None:
134134
async with aiohttp.ClientSession() as session:
135-
async with async_timeout.timeout(10):
135+
async with asyncio.timeout(10):
136136
async with session.get(uri, headers=headers) as resp:
137137
await checkResponseForError(await resp.text())
138138
return await resp.text()
139139
else:
140-
async with async_timeout.timeout(10):
140+
async with asyncio.timeout(10):
141141
async with self.session.get(uri, headers=headers) as resp:
142142
await checkResponseForError(await resp.text())
143143
return await resp.text()
@@ -163,7 +163,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
163163
}
164164
if self.session is None:
165165
async with aiohttp.ClientSession() as session:
166-
async with async_timeout.timeout(10):
166+
async with asyncio.timeout(10):
167167
async with session.post(
168168
CONTROLLER_AUTHORIZATION_ENDPOINT,
169169
headers=headers,
@@ -172,7 +172,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
172172
await checkResponseForError(await resp.text())
173173
return await resp.text()
174174
else:
175-
async with async_timeout.timeout(10):
175+
async with asyncio.timeout(10):
176176
async with self.session.post(
177177
CONTROLLER_AUTHORIZATION_ENDPOINT,
178178
headers=headers,

docs/auth.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ <h1 class="title">Module <code>pyControl4.auth</code></h1>
7575
}
7676
}
7777
async with aiohttp.ClientSession() as session:
78-
async with async_timeout.timeout(10):
78+
async with asyncio.timeout(10):
7979
async with session.post(
8080
AUTHENTICATION_ENDPOINT, json=dataDictionary
8181
) as resp:
@@ -96,7 +96,7 @@ <h1 class="title">Module <code>pyControl4.auth</code></h1>
9696
_LOGGER.error(msg)
9797
raise
9898
async with aiohttp.ClientSession() as session:
99-
async with async_timeout.timeout(10):
99+
async with asyncio.timeout(10):
100100
async with session.get(uri, headers=headers) as resp:
101101
return await resp.text()
102102

@@ -121,7 +121,7 @@ <h1 class="title">Module <code>pyControl4.auth</code></h1>
121121
}
122122
}
123123
async with aiohttp.ClientSession() as session:
124-
async with async_timeout.timeout(10):
124+
async with asyncio.timeout(10):
125125
async with session.post(
126126
CONTROLLER_AUTHORIZATION_ENDPOINT,
127127
headers=headers,
@@ -276,7 +276,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
276276
}
277277
}
278278
async with aiohttp.ClientSession() as session:
279-
async with async_timeout.timeout(10):
279+
async with asyncio.timeout(10):
280280
async with session.post(
281281
AUTHENTICATION_ENDPOINT, json=dataDictionary
282282
) as resp:
@@ -297,7 +297,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
297297
_LOGGER.error(msg)
298298
raise
299299
async with aiohttp.ClientSession() as session:
300-
async with async_timeout.timeout(10):
300+
async with asyncio.timeout(10):
301301
async with session.get(uri, headers=headers) as resp:
302302
return await resp.text()
303303

@@ -322,7 +322,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
322322
}
323323
}
324324
async with aiohttp.ClientSession() as session:
325-
async with async_timeout.timeout(10):
325+
async with asyncio.timeout(10):
326326
async with session.post(
327327
CONTROLLER_AUTHORIZATION_ENDPOINT,
328328
headers=headers,
@@ -651,4 +651,4 @@ <h4><code><a title="pyControl4.auth.C4Auth" href="#pyControl4.auth.C4Auth">C4Aut
651651
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
652652
<script>hljs.initHighlightingOnLoad()</script>
653653
</body>
654-
</html>
654+
</html>

docs/director.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9999
async with aiohttp.ClientSession(
100100
connector=aiohttp.TCPConnector(verify_ssl=False)
101101
) as session:
102-
async with async_timeout.timeout(10):
102+
async with asyncio.timeout(10):
103103
async with session.get(
104104
self.base_url + uri, headers=self.headers
105105
) as resp:
106106
await checkResponseForError(await resp.text())
107107
return await resp.text()
108108
else:
109-
async with async_timeout.timeout(10):
109+
async with asyncio.timeout(10):
110110
async with self.session.get(
111111
self.base_url + uri, headers=self.headers
112112
) as resp:
@@ -135,14 +135,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
135135
async with aiohttp.ClientSession(
136136
connector=aiohttp.TCPConnector(verify_ssl=False)
137137
) as session:
138-
async with async_timeout.timeout(10):
138+
async with asyncio.timeout(10):
139139
async with session.post(
140140
self.base_url + uri, headers=self.headers, json=dataDictionary
141141
) as resp:
142142
await checkResponseForError(await resp.text())
143143
return await resp.text()
144144
else:
145-
async with async_timeout.timeout(10):
145+
async with asyncio.timeout(10):
146146
async with self.session.post(
147147
self.base_url + uri, headers=self.headers, json=dataDictionary
148148
) as resp:
@@ -783,14 +783,14 @@ <h2 id="returns">Returns</h2>
783783
async with aiohttp.ClientSession(
784784
connector=aiohttp.TCPConnector(verify_ssl=False)
785785
) as session:
786-
async with async_timeout.timeout(10):
786+
async with asyncio.timeout(10):
787787
async with session.get(
788788
self.base_url + uri, headers=self.headers
789789
) as resp:
790790
await checkResponseForError(await resp.text())
791791
return await resp.text()
792792
else:
793-
async with async_timeout.timeout(10):
793+
async with asyncio.timeout(10):
794794
async with self.session.get(
795795
self.base_url + uri, headers=self.headers
796796
) as resp:
@@ -833,14 +833,14 @@ <h2 id="parameters">Parameters</h2>
833833
async with aiohttp.ClientSession(
834834
connector=aiohttp.TCPConnector(verify_ssl=False)
835835
) as session:
836-
async with async_timeout.timeout(10):
836+
async with asyncio.timeout(10):
837837
async with session.post(
838838
self.base_url + uri, headers=self.headers, json=dataDictionary
839839
) as resp:
840840
await checkResponseForError(await resp.text())
841841
return await resp.text()
842842
else:
843-
async with async_timeout.timeout(10):
843+
async with asyncio.timeout(10):
844844
async with self.session.post(
845845
self.base_url + uri, headers=self.headers, json=dataDictionary
846846
) as resp:

pyControl4/account.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import aiohttp
6-
import async_timeout
6+
import asyncio
77
import json
88
import logging
99

@@ -63,14 +63,14 @@ async def __sendAccountAuthRequest(self):
6363
}
6464
if self.session is None:
6565
async with aiohttp.ClientSession() as session:
66-
async with async_timeout.timeout(10):
66+
async with asyncio.timeout(10):
6767
async with session.post(
6868
AUTHENTICATION_ENDPOINT, json=dataDictionary
6969
) as resp:
7070
await checkResponseForError(await resp.text())
7171
return await resp.text()
7272
else:
73-
async with async_timeout.timeout(10):
73+
async with asyncio.timeout(10):
7474
async with self.session.post(
7575
AUTHENTICATION_ENDPOINT, json=dataDictionary
7676
) as resp:
@@ -93,12 +93,12 @@ async def __sendAccountGetRequest(self, uri):
9393
raise
9494
if self.session is None:
9595
async with aiohttp.ClientSession() as session:
96-
async with async_timeout.timeout(10):
96+
async with asyncio.timeout(10):
9797
async with session.get(uri, headers=headers) as resp:
9898
await checkResponseForError(await resp.text())
9999
return await resp.text()
100100
else:
101-
async with async_timeout.timeout(10):
101+
async with asyncio.timeout(10):
102102
async with self.session.get(uri, headers=headers) as resp:
103103
await checkResponseForError(await resp.text())
104104
return await resp.text()
@@ -124,7 +124,7 @@ async def __sendControllerAuthRequest(self, controller_common_name):
124124
}
125125
if self.session is None:
126126
async with aiohttp.ClientSession() as session:
127-
async with async_timeout.timeout(10):
127+
async with asyncio.timeout(10):
128128
async with session.post(
129129
CONTROLLER_AUTHORIZATION_ENDPOINT,
130130
headers=headers,
@@ -133,7 +133,7 @@ async def __sendControllerAuthRequest(self, controller_common_name):
133133
await checkResponseForError(await resp.text())
134134
return await resp.text()
135135
else:
136-
async with async_timeout.timeout(10):
136+
async with asyncio.timeout(10):
137137
async with self.session.post(
138138
CONTROLLER_AUTHORIZATION_ENDPOINT,
139139
headers=headers,

pyControl4/director.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import aiohttp
6-
import async_timeout
6+
import asyncio
77
import json
88

99
from .error_handling import checkResponseForError
@@ -50,14 +50,14 @@ async def sendGetRequest(self, uri):
5050
async with aiohttp.ClientSession(
5151
connector=aiohttp.TCPConnector(verify_ssl=False)
5252
) as session:
53-
async with async_timeout.timeout(10):
53+
async with asyncio.timeout(10):
5454
async with session.get(
5555
self.base_url + uri, headers=self.headers
5656
) as resp:
5757
await checkResponseForError(await resp.text())
5858
return await resp.text()
5959
else:
60-
async with async_timeout.timeout(10):
60+
async with asyncio.timeout(10):
6161
async with self.session.get(
6262
self.base_url + uri, headers=self.headers
6363
) as resp:
@@ -86,14 +86,14 @@ async def sendPostRequest(self, uri, command, params, async_variable=True):
8686
async with aiohttp.ClientSession(
8787
connector=aiohttp.TCPConnector(verify_ssl=False)
8888
) as session:
89-
async with async_timeout.timeout(10):
89+
async with asyncio.timeout(10):
9090
async with session.post(
9191
self.base_url + uri, headers=self.headers, json=dataDictionary
9292
) as resp:
9393
await checkResponseForError(await resp.text())
9494
return await resp.text()
9595
else:
96-
async with async_timeout.timeout(10):
96+
async with asyncio.timeout(10):
9797
async with self.session.post(
9898
self.base_url + uri, headers=self.headers, json=dataDictionary
9999
) as resp:

pyControl4/websocket.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Handles Websocket connections to a Control4 Director, allowing for real-time updates using callbacks."""
22

33
import aiohttp
4-
import async_timeout
4+
import asyncio
55
import socketio_v4 as socketio
66
import logging
77

@@ -60,7 +60,7 @@ async def on_clientId(self, clientId):
6060
async with aiohttp.ClientSession(
6161
connector=aiohttp.TCPConnector(verify_ssl=False)
6262
) as session:
63-
async with async_timeout.timeout(10):
63+
async with asyncio.timeout(10):
6464
async with session.get(
6565
self.url + self.uri,
6666
params={"JWT": self.token, "SubscriptionClient": clientId},
@@ -71,7 +71,7 @@ async def on_clientId(self, clientId):
7171
self.subscriptionId = data["subscriptionId"]
7272
await self.emit("startSubscription", self.subscriptionId)
7373
else:
74-
async with async_timeout.timeout(10):
74+
async with asyncio.timeout(10):
7575
async with self.session.get(
7676
self.url + self.uri,
7777
params={"JWT": self.token, "SubscriptionClient": clientId},

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
aiohttp
2-
async_timeout
32
xmltodict
43
python-socketio-v4
54
websocket-client

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
aiohttp
2-
async_timeout
32
xmltodict
43
python-socketio-v4
54
websocket-client

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"License :: OSI Approved :: Apache Software License",
1919
"Operating System :: OS Independent",
2020
],
21-
python_requires=">=3.6",
21+
python_requires=">=3.11",
2222
install_requires=[
2323
"aiohttp",
2424
"xmltodict",

0 commit comments

Comments
 (0)