mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 12:42:50 +00:00
specify the timeout option
This commit is contained in:
parent
a57f978678
commit
f5341d4ccd
@ -50,6 +50,9 @@ EXCLUDED_PACKAGES = (
|
|||||||
"pytorch-nightly", "pytorch-nightly-cpu", "ignite-nightly",
|
"pytorch-nightly", "pytorch-nightly-cpu", "ignite-nightly",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# connect and read timeout value
|
||||||
|
TIMEOUT_OPTION = (7, 10)
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format="[%(asctime)s] [%(levelname)s] %(message)s",
|
format="[%(asctime)s] [%(levelname)s] %(message)s",
|
||||||
@ -132,7 +135,7 @@ def sync_installer(repo_url, local_dir: Path):
|
|||||||
local_dir.mkdir(parents=True, exist_ok=True)
|
local_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
def remote_list():
|
def remote_list():
|
||||||
r = requests.get(repo_url)
|
r = requests.get(repo_url, timeout=TIMEOUT_OPTION)
|
||||||
d = pq(r.content)
|
d = pq(r.content)
|
||||||
for tr in d('table').find('tr'):
|
for tr in d('table').find('tr'):
|
||||||
tds = pq(tr).find('td')
|
tds = pq(tr).find('td')
|
||||||
@ -147,7 +150,7 @@ def sync_installer(repo_url, local_dir: Path):
|
|||||||
dst_file = local_dir / filename
|
dst_file = local_dir / filename
|
||||||
|
|
||||||
if dst_file.is_file():
|
if dst_file.is_file():
|
||||||
r = requests.head(pkg_url)
|
r = requests.head(pkg_url, timeout=TIMEOUT_OPTION)
|
||||||
remote_filesize = int(r.headers['content-length'])
|
remote_filesize = int(r.headers['content-length'])
|
||||||
remote_date = parsedate_to_datetime(r.headers['last-modified'])
|
remote_date = parsedate_to_datetime(r.headers['last-modified'])
|
||||||
stat = dst_file.stat()
|
stat = dst_file.stat()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user