From 03b0d5e2501d345c7a7754bd6bcf48f90922672c Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 11 May 2022 14:35:15 -0300 Subject: [PATCH] tracker client: extract default timeout and concurreny. Bump concurrency to 100 --- lbry/torrent/tracker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lbry/torrent/tracker.py b/lbry/torrent/tracker.py index 16446bfdd..82daa87f5 100644 --- a/lbry/torrent/tracker.py +++ b/lbry/torrent/tracker.py @@ -18,6 +18,8 @@ from lbry import version log = logging.getLogger(__name__) CONNECTION_EXPIRES_AFTER_SECONDS = 50 PREFIX = 'LB' # todo: PR BEP20 to add ourselves +DEFAULT_TIMEOUT_SECONDS = 10.0 +DEFAULT_CONCURRENCY_LIMIT = 100 # see: http://bittorrent.org/beps/bep_0015.html and http://xbtt.sourceforge.net/udp_tracker_protocol.html ConnectRequest = namedtuple("ConnectRequest", ["connection_id", "action", "transaction_id"]) ConnectResponse = namedtuple("ConnectResponse", ["action", "transaction_id", "connection_id"]) @@ -75,11 +77,11 @@ def make_peer_id(random_part: Optional[str] = None) -> bytes: class UDPTrackerClientProtocol(asyncio.DatagramProtocol): - def __init__(self, timeout: float = 10.0): + def __init__(self, timeout: float = DEFAULT_TIMEOUT_SECONDS): self.transport = None self.data_queue = {} self.timeout = timeout - self.semaphore = asyncio.Semaphore(10) + self.semaphore = asyncio.Semaphore(DEFAULT_CONCURRENCY_LIMIT) def connection_made(self, transport: asyncio.DatagramTransport) -> None: self.transport = transport