【问题标题】:shelve does not sync to disk before close搁置在关闭前不同步到磁盘
【发布时间】:2020-06-17 12:50:51
【问题描述】:

python 版本从 3.5 更改为 3.7 后,shelve 在调用 sync 方法时不再写入磁盘。但是,当我使用 python 3.5 时,它确实如此。

我还注意到在 python 3.7 上,“db”扩展名被附加到搁置数据库文件中。

有人知道这是什么原因吗?有什么解决方法吗?

【问题讨论】:

    标签: python shelve


    【解决方案1】:

    原来我错过了 python3.7-gdbm 包(它是一个 Ubuntu Xenial 服务器)。

    可以用apt-get安装:

    sudo apt-get install python3.7-gdbm
    

    安装 gdbm 包后,python 将开始将搁置存储为 GNU dbm 而不是 Berkeley DB:

    $ file *
    shelve_obj_berkley:            Berkeley DB (Hash, version 9, native byte-order)
    shelve_obj_gdbm:               GNU dbm 1.x or ndbm database, little endian, old
    

    【讨论】:

    • 如果它解决了您的问题,请接受您的回答(它对我有用)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 2017-12-16
    • 2021-06-16
    • 2017-10-10
    相关资源
    最近更新 更多