Add retry for api state (handling random error)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Nicolas Duhamel 2021-07-21 11:21:33 +02:00
parent e9f0dd3f87
commit de3c9d51b2
2 changed files with 5 additions and 1 deletions

View File

@ -5,7 +5,8 @@ setuptools.setup(
'pyamaha @ git+https://github.com/nduhamel/pyamaha.git@citadel#egg=pyamaha',
'citadel.mqtt @ git+https://git.quimbo.fr/citadel/mqtt.git@master#egg=citadel.mqtt',
'systemd-python==234',
'typer==0.3.2'
'typer==0.3.2',
'tenacity==8.0.1'
]
)

View File

@ -2,6 +2,8 @@ import logging
import json
import requests
from tenacity import retry, stop_after_attempt, wait_fixed
from pyamaha import Device, System, Zone
from citadel.mqtt import Client
@ -39,6 +41,7 @@ class Yamaha:
for action in senario.deactivate:
self.request(action)
@retry(stop=stop_after_attempt(3), wait=wait_fixed(1), reraise=True)
def request(self, request):
try:
r = self._device.request(request)