Skip to content

Commit 03b0d5e

Browse files
committed
tracker client: extract default timeout and concurreny. Bump concurrency to 100
1 parent 6298123 commit 03b0d5e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lbry/torrent/tracker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
log = logging.getLogger(__name__)
1919
CONNECTION_EXPIRES_AFTER_SECONDS = 50
2020
PREFIX = 'LB' # todo: PR BEP20 to add ourselves
21+
DEFAULT_TIMEOUT_SECONDS = 10.0
22+
DEFAULT_CONCURRENCY_LIMIT = 100
2123
# see: http://bittorrent.org/beps/bep_0015.html and http://xbtt.sourceforge.net/udp_tracker_protocol.html
2224
ConnectRequest = namedtuple("ConnectRequest", ["connection_id", "action", "transaction_id"])
2325
ConnectResponse = namedtuple("ConnectResponse", ["action", "transaction_id", "connection_id"])
@@ -75,11 +77,11 @@ def make_peer_id(random_part: Optional[str] = None) -> bytes:
7577

7678

7779
class UDPTrackerClientProtocol(asyncio.DatagramProtocol):
78-
def __init__(self, timeout: float = 10.0):
80+
def __init__(self, timeout: float = DEFAULT_TIMEOUT_SECONDS):
7981
self.transport = None
8082
self.data_queue = {}
8183
self.timeout = timeout
82-
self.semaphore = asyncio.Semaphore(10)
84+
self.semaphore = asyncio.Semaphore(DEFAULT_CONCURRENCY_LIMIT)
8385

8486
def connection_made(self, transport: asyncio.DatagramTransport) -> None:
8587
self.transport = transport

0 commit comments

Comments
 (0)