From 158e7ac44ce733f9151bb1bbf432c33c8cc0132a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Fri, 20 Oct 2023 01:35:30 +0200 Subject: [PATCH] Create a new http client on agent retry --- README.md | 1 - argos/agent.py | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a47ddc..dca80fa 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ Argos is an HTTP monitoring service. It allows you to define a list of websites Todo: -- [ ] Retrying: attempt 1413 ended with: Cannot reopen a client instance, once it has been closed. - [ ] Cleandb should keep max number of results by task - [ ] Do not return empty list on / when no results from agents. - [ ] Last seen agents diff --git a/argos/agent.py b/argos/agent.py index 2ad0b95..75c62c4 100644 --- a/argos/agent.py +++ b/argos/agent.py @@ -32,16 +32,17 @@ class ArgosAgent: self.server = server self.max_tasks = max_tasks self.wait_time = wait_time + self.auth = auth self.agent_id = socket.gethostname() - headers = { - "Authorization": f"Bearer {auth}", - } - self._http_client = httpx.AsyncClient(headers=headers) @retry(after=log_failure, wait=wait_random(min=1, max=2)) async def run(self): logger.info(f"Running agent against {self.server}") + headers = { + "Authorization": f"Bearer {self.auth}", + } + self._http_client = httpx.AsyncClient(headers=headers) async with self._http_client: while True: retry_now = await self._get_and_complete_tasks()