mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
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
This commit is contained in:
parent
69cf92c83b
commit
dbf11ef3db
1 changed files with 4 additions and 4 deletions
|
@ -39,15 +39,15 @@ class ArgosAgent:
|
||||||
self.max_tasks = max_tasks
|
self.max_tasks = max_tasks
|
||||||
self.wait_time = wait_time
|
self.wait_time = wait_time
|
||||||
self.auth = auth
|
self.auth = auth
|
||||||
headers = {
|
|
||||||
"Authorization": f"Bearer {self.auth}",
|
|
||||||
}
|
|
||||||
self._http_client = httpx.AsyncClient(headers=headers)
|
|
||||||
|
|
||||||
self.agent_id = socket.gethostname()
|
self.agent_id = socket.gethostname()
|
||||||
|
|
||||||
@retry(after=log_failure, wait=wait_random(min=1, max=2))
|
@retry(after=log_failure, wait=wait_random(min=1, max=2))
|
||||||
async def run(self):
|
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)
|
logger.info("Running agent against %s", self.server)
|
||||||
async with self._http_client:
|
async with self._http_client:
|
||||||
while "forever":
|
while "forever":
|
||||||
|
|
Loading…
Reference in a new issue