self.info_hash = hashlib.sha1(self.info).digest()
-def _random_file(size: int, rand_src: Random, on_disk: bool) -> tempfile.NamedTemporaryFile:
+def _random_file(size: int, rand_src: Random, on_disk: bool) -> io.BufferedIOBase:
f = tempfile.NamedTemporaryFile(buffering = _BUF_SIZE) if on_disk else io.BytesIO()
try:
while f.tell() < size:
def __post_init__(self):
self.triggered = 0
- def read(self, size: int = -1) -> bytes:
+ def read(self, size: Optional[int] = None) -> bytes:
pre_pos = self.wrapped.tell()
data = self.wrapped.read(size)
erroring = self.error_count is None or self.triggered < self.error_count