From df31c292168429d38fce33b416b20b5963cbae96 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Mon, 23 Sep 2024 11:26:41 +0200 Subject: [PATCH] sweep: #7787 fix: added a 30s gfal2 timeout for downloading the SRR --- .../OccupancyPlugins/WLCGAccountingHTTPJson.py | 2 +- .../Storage/OccupancyPlugins/WLCGAccountingJson.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingHTTPJson.py b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingHTTPJson.py index 5e943da7f41..8e1566abc95 100644 --- a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingHTTPJson.py +++ b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingHTTPJson.py @@ -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: diff --git a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py index 30e794b046a..432d7763c1f 100644 --- a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py +++ b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py @@ -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: @@ -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)