From dbf11ef3dbbb35ea1e4501a73b963cf6d28bddf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Tue, 16 Apr 2024 10:09:02 +0200 Subject: [PATCH 1/2] fix(agent): Do not reuse `http_client` on failures. The `http_client` is instantiated with the agent, and reused all the time. If the connection fails and closes, it's sometimes not possible to reuse it.# Please enter the commit message for your changes. Lines starting Fixes #37 --- argos/agent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/argos/agent.py b/argos/agent.py index fe3d222..a0af955 100644 --- a/argos/agent.py +++ b/argos/agent.py @@ -39,15 +39,15 @@ class ArgosAgent: self.max_tasks = max_tasks self.wait_time = wait_time self.auth = auth - headers = { - "Authorization": f"Bearer {self.auth}", - } - self._http_client = httpx.AsyncClient(headers=headers) self.agent_id = socket.gethostname() @retry(after=log_failure, wait=wait_random(min=1, max=2)) async def run(self): + headers = { + "Authorization": f"Bearer {self.auth}", + } + self._http_client = httpx.AsyncClient(headers=headers) logger.info("Running agent against %s", self.server) async with self._http_client: while "forever": From d881d35be379e5f1c62d130ee2be57036d5301b5 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Thu, 25 Apr 2024 11:58:02 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20=E2=80=94=20Fix=20linter=20w?= =?UTF-8?q?arning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- argos/agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/argos/agent.py b/argos/agent.py index a0af955..7cc3209 100644 --- a/argos/agent.py +++ b/argos/agent.py @@ -39,6 +39,7 @@ class ArgosAgent: self.max_tasks = max_tasks self.wait_time = wait_time self.auth = auth + self._http_client = None self.agent_id = socket.gethostname()