Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def make_release(version, commit_hash, release_notes=""):
"prerelease": Version(version).is_prerelease,
},
headers=headers,
timeout=30,
)
r.raise_for_status()
release_data = r.json()
Expand All @@ -41,6 +42,7 @@ def make_release(version, commit_hash, release_notes=""):
"draft": False,
},
headers=headers,
timeout=30,
)
r.raise_for_status()
release_data = r.json()
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Security/IAMService.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _getIamPagedResources(self, url):
totalResults = 1000 # total number of users
itemsPerPage = 10
while startIndex <= totalResults:
resp = requests.get(url, headers=headers, params={"startIndex": startIndex})
resp = requests.get(url, headers=headers, params={"startIndex": startIndex}, timeout=30)
resp.raise_for_status()
data = resp.json()
# These 2 should never change while looping
Expand Down
3 changes: 2 additions & 1 deletion src/DIRAC/Core/Security/VOMSService.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def getUsers(self):
cert=getProxyLocation(),
verify=getCAsLocation(),
params={"startIndex": str(startIndex), "pageSize": "100"},
timeout=30,
)
except requests.ConnectionError as exc:
except (requests.ConnectionError,requests.Timeout) as exc:
error = f"{url}:{repr(exc)}"
urlDone = True
continue
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/DataManagementSystem/Client/FTS3Job.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_scitag(vo: str, activity: Optional[str] = None) -> int:
@cached(_scitag_json_cache, lock=_scitag_json_lock)
def get_remote_json():
gLogger.verbose("Fetching https://scitags.org/api.json from the network")
response = requests.get("https://scitags.org/api.json")
response = requests.get("https://scitags.org/api.json", timeout=30)
response.raise_for_status()
return response.json()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def export_updateSoftware(self, version):
)
self.log.info("Downloading DIRACOS2 installer from", installer_url)
with tempfile.NamedTemporaryFile(suffix=".sh", mode="wb") as installer:
with requests.get(installer_url, stream=True) as r:
with requests.get(installer_url, timeout=30, stream=True) as r:
if not r.ok:
return S_ERROR(f"Failed to download {installer_url}")
for chunk in r.iter_content(chunk_size=1024**2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ def sendSlackMessage(self, message):
"""

payload = {"text": message}
response = requests.post(self.url, data=json.dumps(payload), headers={"Content-Type": "application/json"})
response = requests.post(self.url, data=json.dumps(payload), headers={"Content-Type": "application/json"}, timeout=30)
response.raise_for_status()
return S_OK()
2 changes: 2 additions & 0 deletions src/DIRAC/Resources/IdProvider/OAuth2IdProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ def submitDeviceCodeAuthorizationFlow(self, group=None):
self.get_metadata("device_authorization_endpoint"),
data=dict(client_id=self.client_id, scope=list_to_scope(scope_to_list(self.scope) + groupScopes)),
verify=self.verify,
timeout=30,
)
r.raise_for_status()
deviceResponse = r.json()
Expand Down Expand Up @@ -616,6 +617,7 @@ def waitFinalStatusOfDeviceCodeAuthorizationFlow(self, deviceCode, interval=5, t
self.get_metadata("token_endpoint"),
data=dict(client_id=self.client_id, grant_type=DEVICE_CODE_GRANT_TYPE, device_code=deviceCode),
verify=self.verify,
timeout=30,
)
token = r.json()
if not token:
Expand Down
12 changes: 6 additions & 6 deletions src/DIRAC/Resources/Storage/S3Storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _getKeyFromURL(self, url):
# failed[key] = res['Message']
# continue
# presignedURL = res['Value']
# response = requests.get(presignedURL)
# response = requests.get(presignedURL, timeout=30)
# if response.status_code == 200:
# successful[key] = True
# elif response.status_code == 404: # not found
Expand Down Expand Up @@ -268,7 +268,7 @@ def _presigned_exists(self, urls):
# and perform it with requests
for url, presignedURL in presignedURLs.items():
try:
response = requests.get(presignedURL)
response = requests.get(presignedURL, timeout=30)
if response.status_code == 200:
successful[url] = True
elif response.status_code == 404: # not found
Expand Down Expand Up @@ -373,7 +373,7 @@ def _presigned_getFile(self, urls, localPath=False):

# Stream download to save memory
# https://requests.readthedocs.io/en/latest/user/advanced/#body-content-workflow
with requests.get(presignedURL, stream=True) as r:
with requests.get(presignedURL, timeout=30, stream=True) as r:
r.raise_for_status()
with open(dest_file, "wb") as f:
for chunk in r.iter_content():
Expand Down Expand Up @@ -489,7 +489,7 @@ def _presigned_putFile(self, urls, sourceSize=0):
with open(src_file, "rb") as src_fd:
# files = {'file': (dest_key, src_fd)}
files = {"file": src_fd}
response = requests.post(presignedURL, data=presignedFields, files=files)
response = requests.post(presignedURL, data=presignedFields, files=files, timeout=30)

if not response.ok:
raise Exception(response.reason)
Expand Down Expand Up @@ -567,7 +567,7 @@ def _presigned_getFileMetadata(self, urls):

for url, presignedURL in presignedURLs.items():
try:
response = requests.head(presignedURL)
response = requests.head(presignedURL, timeout=30)
if not response.ok:
raise Exception(response.reason)

Expand Down Expand Up @@ -652,7 +652,7 @@ def _presigned_removeFile(self, urls):

for url, presignedURL in presignedURLs.items():
try:
response = requests.delete(presignedURL)
response = requests.delete(presignedURL, timeout=30)
if not response.ok:
raise Exception(response.reason)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def execute(self):
self.log.info("Attempting to upload", f"to {server}")
if server.startswith("https://"):
for tf in allFiles:
res = requests.put(server, data=tf, verify=self.casLocation, cert=self.certAndKeyLocation)
res = requests.put(server, data=tf, verify=self.casLocation, cert=self.certAndKeyLocation, timeout=30)
if res.status_code not in (200, 202):
self.log.error("Could not upload", f"to {server}: status {res.status_code}")
else: # Assumes this is a DIRAC SE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def _sendToClient(self, fileID, token, fileHelper=None, raw=False):
if filePath.startswith("/S3"):
with TheImpersonator(credDict, source="SandboxStore") as client:
res = client.jobs.get_sandbox_file(pfn=filePath)
r = requests.get(res.url)
r = requests.get(res.url, timeout=30)
r.raise_for_status()
sbData = r.content
if fileHelper:
Expand Down
Loading