summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pycontrol4/asyncio-timeout.patch
blob: c622815a8cca8156bccb9686a613b3fec062084d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
commit d110f0ae9a85f42858140c3cc325e69136f5da2f
Author: Martin Weinelt <hexa@darmstadt.ccc.de>
Date:   Mon Nov 10 01:54:08 2025 +0100

    Use native asyncio.timeout from python stdlib
    
    This drops the dependency on async_timeout and bumps the required Python
    version to 3.11, which is when asyncio.timeout was introduced.

diff --git a/pyControl4/account.py b/pyControl4/account.py
index 658f1b3..60c6cd9 100644
--- a/pyControl4/account.py
+++ b/pyControl4/account.py
@@ -3,7 +3,7 @@ controller info, and retrieves a bearer token for connecting to a Control4 Direc
 """
 
 import aiohttp
-import async_timeout
+import asyncio
 import json
 import logging
 import datetime
@@ -64,14 +64,14 @@ class C4Account:
         }
         if self.session is None:
             async with aiohttp.ClientSession() as session:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with session.post(
                         AUTHENTICATION_ENDPOINT, json=dataDictionary
                     ) as resp:
                         await checkResponseForError(await resp.text())
                         return await resp.text()
         else:
-            with async_timeout.timeout(10):
+            async with asyncio.timeout(10):
                 async with self.session.post(
                     AUTHENTICATION_ENDPOINT, json=dataDictionary
                 ) as resp:
@@ -94,12 +94,12 @@ class C4Account:
             raise
         if self.session is None:
             async with aiohttp.ClientSession() as session:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with session.get(uri, headers=headers) as resp:
                         await checkResponseForError(await resp.text())
                         return await resp.text()
         else:
-            with async_timeout.timeout(10):
+            async with asyncio.timeout(10):
                 async with self.session.get(uri, headers=headers) as resp:
                     await checkResponseForError(await resp.text())
                     return await resp.text()
@@ -125,7 +125,7 @@ class C4Account:
         }
         if self.session is None:
             async with aiohttp.ClientSession() as session:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with session.post(
                         CONTROLLER_AUTHORIZATION_ENDPOINT,
                         headers=headers,
@@ -134,7 +134,7 @@ class C4Account:
                         await checkResponseForError(await resp.text())
                         return await resp.text()
         else:
-            with async_timeout.timeout(10):
+            async with asyncio.timeout(10):
                 async with self.session.post(
                     CONTROLLER_AUTHORIZATION_ENDPOINT,
                     headers=headers,
diff --git a/pyControl4/director.py b/pyControl4/director.py
index d2bf551..764959d 100644
--- a/pyControl4/director.py
+++ b/pyControl4/director.py
@@ -3,7 +3,7 @@ getting details about items on the Director.
 """
 
 import aiohttp
-import async_timeout
+import asyncio
 import json
 
 from .error_handling import checkResponseForError
@@ -50,14 +50,14 @@ class C4Director:
             async with aiohttp.ClientSession(
                 connector=aiohttp.TCPConnector(verify_ssl=False)
             ) as session:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with session.get(
                         self.base_url + uri, headers=self.headers
                     ) as resp:
                         await checkResponseForError(await resp.text())
                         return await resp.text()
         else:
-            with async_timeout.timeout(10):
+            async with asyncio.timeout(10):
                 async with self.session.get(
                     self.base_url + uri, headers=self.headers
                 ) as resp:
@@ -86,14 +86,14 @@ class C4Director:
             async with aiohttp.ClientSession(
                 connector=aiohttp.TCPConnector(verify_ssl=False)
             ) as session:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with session.post(
                         self.base_url + uri, headers=self.headers, json=dataDictionary
                     ) as resp:
                         await checkResponseForError(await resp.text())
                         return await resp.text()
         else:
-            with async_timeout.timeout(10):
+            async with asyncio.timeout(10):
                 async with self.session.post(
                     self.base_url + uri, headers=self.headers, json=dataDictionary
                 ) as resp:
diff --git a/pyControl4/websocket.py b/pyControl4/websocket.py
index 1ee67f2..e8bb37d 100644
--- a/pyControl4/websocket.py
+++ b/pyControl4/websocket.py
@@ -1,7 +1,7 @@
 """Handles Websocket connections to a Control4 Director, allowing for real-time updates using callbacks."""
 
 import aiohttp
-import async_timeout
+import asyncio
 import socketio_v4 as socketio
 import logging
 
@@ -60,7 +60,7 @@ class _C4DirectorNamespace(socketio.AsyncClientNamespace):
                 async with aiohttp.ClientSession(
                     connector=aiohttp.TCPConnector(verify_ssl=False)
                 ) as session:
-                    with async_timeout.timeout(10):
+                    async with asyncio.timeout(10):
                         async with session.get(
                             self.url + self.uri,
                             params={"JWT": self.token, "SubscriptionClient": clientId},
@@ -71,7 +71,7 @@ class _C4DirectorNamespace(socketio.AsyncClientNamespace):
                             self.subscriptionId = data["subscriptionId"]
                             await self.emit("startSubscription", self.subscriptionId)
             else:
-                with async_timeout.timeout(10):
+                async with asyncio.timeout(10):
                     async with self.session.get(
                         self.url + self.uri,
                         params={"JWT": self.token, "SubscriptionClient": clientId},