Skip to content

Commit

Permalink
tracker client: extract default timeout and concurreny. Bump concurre…
Browse files Browse the repository at this point in the history
…ncy to 100
  • Loading branch information
shyba committed May 11, 2022
1 parent 4171e9c commit 93f2ad8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lbry/torrent/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
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"])
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 93f2ad8

Please sign in to comment.