1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

Add separate hooks for major state objects, add tests

This commit is contained in:
thatmattlove
2021-09-16 13:46:50 -07:00
parent c99f98a6f0
commit e06ea5ecb9
30 changed files with 549 additions and 263 deletions

View File

@@ -47,10 +47,10 @@ def handle_timeout(**exc_args: Any) -> Callable:
async def execute(query: "Query") -> Union["OutputDataModel", str]:
"""Initiate query validation and execution."""
state = use_state()
output = state.params.messages.general
params = use_state("params")
output = params.messages.general
log.debug("Received query for {}", query.json())
log.debug("Received query {}", query.json())
log.debug("Matched device config: {}", query.device)
mapped_driver = map_driver(query.device.driver)
@@ -60,7 +60,7 @@ async def execute(query: "Query") -> Union["OutputDataModel", str]:
signal.SIGALRM,
handle_timeout(error=TimeoutError("Connection timed out"), device=query.device),
)
signal.alarm(state.params.request_timeout - 1)
signal.alarm(params.request_timeout - 1)
if query.device.proxy:
proxy = driver.setup_proxy()