aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--pyagl/services/base.py8
2 files changed, 8 insertions, 1 deletions
diff --git a/README.md b/README.md
index d81cf82..6f690e5 100644
--- a/README.md
+++ b/README.md
@@ -92,6 +92,7 @@ Note that the tests have been labelled with `pytest` markers to allow selecting
When running tests on target, AGL_TGT_IP is not required, as the tests will assume the local host is the target.
Some specific tests are dependent on additional configuration via the following environment variables:
+* AGL_TEST_TIMEOUT - optional, over-ride the default 5 second timeout value for binding responses.
* AGL_AVAILABLE_INTERFACES - optional, specify which of ethernet, wifi, and bluetooth interfaces are available. The value is a comma separated list, with a default value of "ethernet,wifi,bluetooth".
* AGL_BTMAP_RECIPIENT - optional, when running Bluetooth MAP tests, this would be used as phone number to write text messages to.
* AGL_BTMAP_TEXT - optional, when running Bluetooth MAP tests, messages will be composed with this text.
diff --git a/pyagl/services/base.py b/pyagl/services/base.py
index cd69f55..b7f76d0 100644
--- a/pyagl/services/base.py
+++ b/pyagl/services/base.py
@@ -144,6 +144,10 @@ class AGLBaseService:
self.service = service
self.runsvc = runservice
self.logger = logging.getLogger(service)
+ try:
+ self.timeout = float(os.environ.get('AGL_TEST_TIMEOUT', timeout))
+ except ValueError:
+ self.timeout = 5.0
def __await__(self):
return self._async_init().__await__()
@@ -324,7 +328,7 @@ class AGLBaseService:
async def response(self):
try:
- msg = await self.websocket.recv()
+ msg = await asyncio.wait_for(self.websocket.recv(), self.timeout)
try:
data = json.loads(msg)
self.logger.debug('[AGL] -> ' + msg)
@@ -342,6 +346,8 @@ class AGLBaseService:
self.logger.debug("Received keyboard interrupt, exiting")
except asyncio.CancelledError:
self.logger.warning("Websocket listener coroutine stopped")
+ except asyncio.TimeoutError:
+ self.logger.warning("Response wait timed out")
except Exception as e:
self.logger.error("Unhandled seal: " + str(e))