mirror of
https://github.com/codex-storage/bittorrent-benchmarks.git
synced 2025-02-22 15:58:11 +00:00
23 lines
576 B
Python
23 lines
576 B
Python
import socket
|
|
|
|
import requests
|
|
from requests.exceptions import ConnectionError
|
|
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
|
|
except (ConnectionError, socket.gaierror):
|
|
return False
|
|
|
|
def __str__(self) -> str:
|
|
return f"Tracker({self.announce_url})"
|