2024-12-04 19:04:57 -03:00
|
|
|
import socket
|
|
|
|
|
2024-12-03 17:50:27 -03:00
|
|
|
import requests
|
|
|
|
from urllib3.util import Url
|
|
|
|
|
|
|
|
from benchmarks.core.experiments.experiments import ExperimentComponent
|
|
|
|
|
|
|
|
|
|
|
|
class Tracker(ExperimentComponent):
|
|
|
|
def __init__(self, announce_url: Url):
|
|
|
|
self.announce_url = announce_url
|
|
|
|
|
|
|
|
def is_ready(self) -> bool:
|
|
|
|
try:
|
|
|
|
requests.get(str(self.announce_url))
|
|
|
|
return True
|
2024-12-04 19:04:57 -03:00
|
|
|
except (ConnectionError, socket.gaierror):
|
2024-12-03 17:50:27 -03:00
|
|
|
return False
|
2024-12-06 14:18:30 -03:00
|
|
|
|
|
|
|
def __str__(self) -> str:
|
2024-12-14 06:34:11 -03:00
|
|
|
return f"Tracker({self.announce_url})"
|