繁体   English   中英

有没有办法增加 tinydb JSON 限制?

[英]Is there a way to increase tinydb JSON limit?

我有一个 tinydb json 文件,但我注意到在某个时候它拒绝向 json 文件写入更多项目并在解析时抛出错误,因为它在写入项目的过程中中断

这就是回溯。 它显示 json 解析器无法解析,因为作者在项目中间切断了写作

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "main.py", line 79, in run
    message.process()
  File "C:\Users\Administrator\Downloads\dbtest\Login_Message.py", line 45, in process
    DataBase.loadAccount(self)
  File "C:\Users\Administrator\Downloads\dbtest\DataBase.py", line 9, in loadAccount
    user_data = db.search(query.token == str(user.token))
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in search
    docs = [doc for doc in self if cond(doc)]
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 234, in <listcomp>
    docs = [doc for doc in self if cond(doc)]
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 588, in __iter__
    for doc_id, doc in self._read_table().items():
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\table.py", line 638, in _read_table
    tables = self._storage.read()
  File "C:\Program Files (x86)\Python38-32\lib\site-packages\tinydb\storages.py", line 125, in read
    return json.load(self._handle)
  File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Program Files (x86)\Python38-32\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files (x86)\Python38-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 234357 (char 234356)

发生这种情况的原因是因为多个线程同时写入 db 文件所以我最终手动写入多个文件:每个条目一个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM