Skip to content

Commit

Permalink
fix: added a 30s gfal2 timeout for downloading the SRR
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Sep 17, 2024
1 parent 3fc58a8 commit db1768a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _downloadJsonFile(self, occupancyLFN, filePath):
with open(filePath, "w") as fd:
caPath = getCAsLocation()
userProxy = getProxyLocation()
res = requests.get(occupancyLFN, cert=userProxy, verify=caPath)
res = requests.get(occupancyLFN, cert=userProxy, verify=caPath, timeout=30)
res.raise_for_status()
fd.write(res.text)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
When this is used, the OccupancyLFN has to be the full path on the storage, and not just the LFN
"""
import errno
import json
import os
import tempfile
import shutil
import errno
import tempfile

import gfal2 # pylint: disable=import-error

from DIRAC import S_OK, S_ERROR
from DIRAC import S_ERROR, S_OK
from DIRAC.Resources.Storage.GFAL2_StorageBase import setGfalSetting


class WLCGAccountingJson:
Expand All @@ -39,11 +41,13 @@ def _downloadJsonFile(self, occupancyLFN, filePath):
ctx = gfal2.creat_context()
params = ctx.transfer_parameters()
params.overwrite = True
params.timeout = 30
res = storage.updateURL(occupancyLFN)
if not res["OK"]:
continue
occupancyURL = res["Value"]
ctx.filecopy(params, occupancyURL, "file://" + filePath)
with setGfalSetting(ctx, "HTTP PLUGIN", "OPERATION_TIMEOUT", 30):
ctx.filecopy(params, occupancyURL, "file://" + filePath)
# Just make sure the file is json, and not SSO HTML
with open(filePath) as f:
json.load(f)
Expand Down

0 comments on commit db1768a

Please sign in to comment.