Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 67d59a2

Browse files
committedOct 10, 2022
Add a timeout to the get request
as suggested by pylint W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout) (fix pylint)
1 parent 22ac8b4 commit 67d59a2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎src/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def download_pdb(pdb_id: str, directory: str, compressed: bool = True) -> str:
6969
pdb_url = DOWNLOAD_URL + pdb_id + '.pdb' + gzip_ext
7070
# print('Downloading PDB file from RCSB website:', pdb_url)
7171
dest = os.path.join(directory, pdb_id + '.pdb' + gzip_ext)
72-
response = requests.get(pdb_url)
72+
response = requests.get(pdb_url, timeout=60)
7373
if response.status_code == 404:
7474
print(f'PDB file not found: {pdb_id}')
7575
# Write an empty file to indicate that the PDB file was not found.

‎src/rcsbids.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _send_request(query: str) -> dict:
3838
"""
3939
# Documentation URL: https://search.rcsb.org/#search-api
4040
url_get = 'https://search.rcsb.org/rcsbsearch/v2/query?json=' + query
41-
response = requests.get(url_get)
41+
response = requests.get(url_get, timeout=60)
4242
response.raise_for_status()
4343
# Handle 204 No Content response
4444
return {} if response.status_code == 204 else response.json()

0 commit comments

Comments
 (0)
Please sign in to comment.