Skip to content

Commit 4949e94

Browse files
committed
Version bump to try to fix a Wyoming issue.
1 parent 3f835dd commit 4949e94

4 files changed

Lines changed: 43 additions & 38 deletions

File tree

‎.vscode/launch.json‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"configurations": [
77
{
88
"name": "Linux Host",
9-
"type": "python",
9+
"type": "debugpy",
1010
"request": "launch",
1111
"module": "homeway_linuxhost",
12+
"python": "~/.homeway-env/bin/python",
1213
"cwd": "${fileWorkspaceFolder}/homeway",
1314
"justMyCode": false,
1415
"args": [
@@ -19,13 +20,14 @@
1920
"eyJWZXJzaW9uRmlsZURpciI6Ii9ob21lL3BpL2hvbWV3YXkvaG9tZXdheSIsICJBZGRvbkRhdGFSb290RGlyIjoiL2hvbWUvcGkvLmhvbWV3YXktYWRkb24iLCAiTG9nc0RpciI6Ii9ob21lL3BpLy5ob21ld2F5LWFkZG9uL2xvZ3MiLCAiU3RvcmFnZURpciI6Ii9ob21lL3BpLy5ob21ld2F5LWFkZG9uL2RhdGEiLCAiSXNSdW5uaW5nSW5IYUFkZG9uRW52IjpmYWxzZSB9",
2021
//
2122
// We can optionally pass a dev config json object, which has dev specific overwrites we can make.
22-
"{\"LocalHomewayServerAddress\": \"10.0.0.15\" , \"LogLevel\":\"DEBUG\"}"
23+
"{\"LocalHomewayServerAddress\": \"\" , \"LogLevel\":\"DEBUG\"}"
2324
]
2425
},
2526
{
2627
"name": "Installer Module",
27-
"type": "python",
28+
"type": "debugpy",
2829
"request": "launch",
30+
"python": "~/.homeway-env/bin/python",
2931
"module": "homeway_installer",
3032
"justMyCode": false,
3133
"args": [
@@ -37,9 +39,10 @@
3739
},
3840
{
3941
"name": "Linux Host - WSL",
40-
"type": "python",
42+
"type": "debugpy",
4143
"request": "launch",
4244
"module": "homeway_linuxhost",
45+
"python": "~/.homeway-env/bin/python",
4346
"cwd": "${fileWorkspaceFolder}/homeway",
4447
"justMyCode": false,
4548
"args": [

‎homeway/config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ image: ghcr.io/homewayio/homeway/{arch}
5353
# Note when this version number changes, we must make a release to start a docker container build immediately, since HA will start looking for the new version.
5454
# Basically: Make the final commit -> test and check lint actions (if a docker change, push to docker-test to ensure it builds) -> bump the version number -> create GitHub release.
5555
# UPDATE THE CHANGE LOG!
56-
version: 2.2.6
56+
version: 2.2.7

‎homeway/homeway_linuxhost/sage/sagehandler.py‎

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import json
33
import logging
44
import threading
5-
import requests
5+
import asyncio
6+
import aiohttp
67

78
from wyoming.asr import Transcript, Transcribe
89
from wyoming.tts import Synthesize
@@ -236,40 +237,40 @@ async def _HandleDescribe(self) -> bool:
236237

237238
# Since this is important, we have some retry logic.
238239
attempt = 0
239-
while True:
240-
attempt += 1
241-
242-
# Attempt getting a valid response.
243-
serviceInfo:Info = None
244-
try:
245-
self.Logger.debug(f"Sage - Starting Info Service Request - {url}")
246-
# Attempt to get and parse the info object.
247-
response = requests.get(url, timeout=10)
248-
if response.status_code == 200:
249-
serviceInfo = self._BuildInfoEvent(response.json())
250-
if serviceInfo is None:
251-
raise Exception("Failed to build info event.")
252-
else:
253-
self.Logger.warning(f"Sage - Failed to get models from service. Attempt: {attempt} - {response.status_code}")
254-
except Exception as e:
255-
self.Logger.warning(f"Sage - Failed to get models from service. Attempt: {attempt} - {e}")
256-
257-
# If we got service info, try to write it to the client.
258-
if serviceInfo is not None:
259-
self.Logger.debug("Sage - Service request successful, sending to Wyoming protocol.")
240+
async with aiohttp.ClientSession() as session:
241+
while True:
242+
attempt += 1
243+
serviceInfo:Info = None
260244
try:
261-
await self._CacheAndWriteInfoEvent(serviceInfo)
262-
# Success
263-
return True
245+
self.Logger.debug(f"Sage - Starting Info Service Request - {url}")
246+
# Perform the async GET request with a timeout of 10 seconds.
247+
async with session.get(url, timeout=10) as response:
248+
if response.status == 200:
249+
data = await response.json()
250+
serviceInfo = self._BuildInfoEvent(data)
251+
if serviceInfo is None:
252+
raise Exception("Failed to build info event.")
253+
else:
254+
self.Logger.warning(f"Sage - Failed to get models from service. Attempt: {attempt} - {response.status}")
264255
except Exception as e:
265-
self.Logger.warning(f"Sage - Failed to send info to wyoming protocol. Attempt: {attempt} - {e}")
266-
267-
# If we fail, try a few times. Throw when we hit the limit.
268-
if attempt > 3:
269-
raise Exception("Failed to get models from service after 3 attempts.")
270-
271-
# Sleep before trying again.
272-
time.sleep(5)
256+
self.Logger.warning(f"Sage - Failed to get models from service. Attempt: {attempt} - {e}")
257+
258+
# If we got valid serviceInfo, try to process it.
259+
if serviceInfo is not None:
260+
self.Logger.debug("Sage - Service request successful, sending to Wyoming protocol.")
261+
try:
262+
await self._CacheAndWriteInfoEvent(serviceInfo)
263+
# Success, exit the function.
264+
return True
265+
except Exception as e:
266+
self.Logger.warning(f"Sage - Failed to send info to wyoming protocol. Attempt: {attempt} - {e}")
267+
268+
# After 3 attempts, raise an exception.
269+
if attempt > 3:
270+
raise Exception("Failed to get models from service after 3 attempts.")
271+
272+
# Wait 5 seconds before retrying.
273+
await asyncio.sleep(5)
273274

274275
except Exception as e:
275276
Sentry.Exception("Sage - Failed get info from service.", e)

‎homeway/requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ octoflatbuffers==24.3.27
2626
# Keep these as current as possible.
2727
requests>=2.32.3
2828
urllib3>=2.2.0
29+
aiohttp>=3.10.0
2930
certifi>=2025.1.31
3031
rsa>=4.9
3132
dnspython>=2.6.0

0 commit comments

Comments
 (0)