Browse Source

Add a timeout to prevent potentially indefinite blocking

master
JustAnotherArchivist 2 years ago
parent
commit
1686e04cbe
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      ia-verify-file

+ 2
- 2
ia-verify-file View File

@@ -17,7 +17,7 @@ if len(item) > 100 or item[0] not in (string.ascii_letters + string.digits) or i
sys.exit(1)

# Fetch https://archive.org/metadata/ITEM to get the two servers that store the item
conn = http.client.HTTPSConnection('archive.org')
conn = http.client.HTTPSConnection('archive.org', timeout = 30)
conn.request('GET', f'/metadata/{item}')
r = conn.getresponse()
if r.status != 200:
@@ -37,7 +37,7 @@ if len(o['workable_servers']) < 2:

# Fetch _files.xml from each server and compare hash
for server in o['workable_servers']:
conn = http.client.HTTPSConnection(server)
conn = http.client.HTTPSConnection(server, timeout = 30)
conn.request('GET', f'{o["dir"]}/{item}_files.xml')
r = conn.getresponse()
if r.status != 200:


Loading…
Cancel
Save