opensciencegrid / xcache

Settings and configurations for an XRootD Caching Proxy
https://opensciencegrid.org/docs/data/stashcache/install-cache/
Apache License 2.0
4 stars 13 forks source link

Open state file as str, not bytes because that is what json.load()/json.dump() expect #123

Closed matyasselmeci closed 2 years ago

matyasselmeci commented 2 years ago

Based on this traceback:

/usr/libexec/xcache/xcache-reporter --one-shot --verbose
WARNING: Could not parse cache state file /tmp/stashcache-reporter.stash.json: Expecting value: line 1 column 1 (char 0)
INFO: Cache stat collection for /stash took 0.01 seconds
Process Process-3:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/libexec/xcache/xcache-reporter", line 100, in stat_collector
    self.walk_cache()
  File "/usr/libexec/xcache/xcache-reporter", line 122, in walk_cache
    self.save_state()
  File "/usr/libexec/xcache/xcache-reporter", line 92, in save_state
    json.dump(dict(self.state), fptr)
  File "/usr/lib64/python3.6/json/__init__.py", line 180, in dump
    fp.write(chunk)
TypeError: a bytes-like object is required, not 'str'

See #122 for the PR against the V2 series.