DIRACGrid / DIRAC

DIRAC Grid
http://diracgrid.org
GNU General Public License v3.0
113 stars 176 forks source link

Resource leak (unclosed file) in WMS #7641

Closed maxnoe closed 5 months ago

maxnoe commented 5 months ago

We are running tests with warnings turned into errors by default and this lead us to an unclosed file resource warning in the WMS:

  Traceback (most recent call last):
    File "/home/dirac/diracos/lib/python3.11/site-packages/DIRAC/WorkloadManagementSystem/Client/SandboxStoreClient.py", line 163, in uploadFilesAsSandbox
      result = transferClient.sendFile(tmpFilePath, [f"{oMD5.hexdigest()}.tar.bz2", assignTo])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/LDSB.worp7w_b' mode='r' encoding='utf-8'>

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

using this simple test in a minimal dirac setup:

def test_job_submission():
    from DIRAC.Interfaces.API.Dirac import Dirac
    from DIRAC.Interfaces.API.Job import Job

    dirac = Dirac()

    job = Job()
    job.setExecutable("echo", arguments="Hello world")
    job.setName("testjob")
    job.setDestination("CTAO.CI.de")
    res = dirac.submitJob(job)
    assert res["OK"]
    job_id = res["Value"]

    wait_for_status(dirac, job_id=job_id, status="Done", timeout=180)
fstagni commented 5 months ago

Would you mind testing https://github.com/DIRACGrid/DIRAC/pull/7651 ?

maxnoe commented 5 months ago

Sure, will come back to you tomorrow

maxnoe commented 5 months ago

@fstagni Warning is gone with your fix, thanks a lot!