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] 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":