Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with config file being overwritten #63

Open
jamespcole opened this issue Jan 8, 2016 · 0 comments
Open

Issue with config file being overwritten #63

jamespcole opened this issue Jan 8, 2016 · 0 comments

Comments

@jamespcole
Copy link

Hi, first off, thanks for this project, it's very cool. I have noticed an issue with reads/writes to the config file in multi-threaded situations though.

If you take a look at line 299 here https://github.com/adewes/blitzdb/blob/master/blitzdb/backends/file/backend.py#L299

save_config appears to always get called regardless of the overwrite_config value, as far as I can tell it gets called everytime the config is loaded. Because the issue is sporadic it's difficult to reproduce with an example but the symptoms are an error message like this:

  File "/home/vagrant/.pyvenv/rcvenv/src/blitzdb-master/blitzdb/backends/file/backend.py", line 111, in __init__
    self.load_config(config, overwrite_config)
  File "/home/vagrant/.pyvenv/rcvenv/src/blitzdb-master/blitzdb/backends/file/backend.py", line 285, in load_config
    self._config = JsonSerializer.deserialize(config_file.read())
  File "/home/vagrant/.pyvenv/rcvenv/src/blitzdb-master/blitzdb/backends/file/serializers.py", line 33, in deserialize
    return json.loads(data.decode('utf-8'))
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

I'm pretty certain that it is due to the file being written and read at the same time. It should be a simple fix, so if I can, I'll issue a PR in the next few days if I can find the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant