Skip to content

Commit

Permalink
close file handles from mkstemp. Fix #5147 (#5148)
Browse files Browse the repository at this point in the history
  • Loading branch information
belforte authored Feb 4, 2022
1 parent 7574477 commit 0fbe5f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/python/CRABClient/Commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ def __call__(self):
self.logger.debug("Proxied webdir is located at %s", proxiedWebDir)

# Download status_cache file
_, local_status_cache_txt = tempfile.mkstemp(dir='/tmp', prefix='crab_status-cache-', suffix='.txt')
_, local_status_cache_pkl = tempfile.mkstemp(dir='/tmp', prefix='crab_status-cache-', suffix='.pkl')
fh, local_status_cache_txt = tempfile.mkstemp(dir='/tmp', prefix='crab_status-cache-', suffix='.txt')
os.close(fh) # no need for a hanlde, curl will write using file name
fh, local_status_cache_pkl = tempfile.mkstemp(dir='/tmp', prefix='crab_status-cache-', suffix='.pkl')
os.close(fh) # no need for a handle, curl will write using file name
gotPickle = False
gotTxt = False
# first: try pickle version
Expand Down
1 change: 1 addition & 0 deletions src/python/CRABClient/CrabRestInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def makeRequest(self, uri=None, data=None, verb='GET'):
self.logger.debug("Encoded data for curl request: %s", data)

fh, path = tempfile.mkstemp(dir='/tmp', prefix='crab_curlData')
os.close(fh) # fh handle is for binary write and inconvenient to use
with open(path, 'w') as f:
f.write(data)

Expand Down

0 comments on commit 0fbe5f7

Please sign in to comment.