mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
Create a new http client on agent retry
This commit is contained in:
parent
93fb9cebca
commit
158e7ac44c
2 changed files with 5 additions and 5 deletions
|
@ -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: <Future at 0x104f39390 state=finished raised RuntimeError> 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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue