MCPcopy Create free account
hub / github.com/ZiniuLu/Python-100-Days / DownloadTask

Class DownloadTask

Day01-15/Day13/multithread3.py:16–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class DownloadTask(threading.Thread):
17
18 def __init__(self, filename):
19 super().__init__()
20 self._filename = filename
21
22 def run(self):
23 print('开始下载%s...' % self._filename)
24 time_to_download = randint(5, 10)
25 print('剩余时间%d秒.' % time_to_download)
26 sleep(time_to_download)
27 print('%s下载完成!' % self._filename)
28
29
30def main():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected