Skip to content

Commit

Permalink
Clients: Resolve ResourceWarning rucio#5522
Browse files Browse the repository at this point in the history
The `token_file` in the baseclient is not closed immediately after its usage. It
gets closed once the garbage collector deletes the FileHandler, but this happens
after an unspecified amount of time. This leads to the `ResourceWarning`.
  • Loading branch information
Joel Dierkes committed May 4, 2022
1 parent 7692f33 commit d125ceb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rucio/client/baseclient.py
Expand Up @@ -866,8 +866,8 @@ def __read_token(self):
return False

try:
token_file_handler = open(self.token_file, 'r')
self.auth_token = token_file_handler.readline()
with open(self.token_file, 'r') as token_file_handler:
self.auth_token = token_file_handler.readline()
self.headers['X-Rucio-Auth-Token'] = self.auth_token
except IOError as error:
print("I/O error({0}): {1}".format(error.errno, error.strerror))
Expand Down

0 comments on commit d125ceb

Please sign in to comment.