[New-bugs-announce] [issue42667] shelve module is not thread-safe during accessing different databases from different threads

gardener.willy report at bugs.python.org
Thu Dec 17 06:05:17 EST 2020


New submission from gardener.willy <gardener.willy at yandex.ru>:

Shelve module uses "import dbm" instruction while opening database. Dbm module has global dictionary "_modules". This dictionary modifies during database opening operation. When different threads simultaneously try to open different databases, unexpected behavior occurred. In my case I've got such message: 

    with shelve.open('some_file') as f:
  File "/usr/local/lib/python3.6/shelve.py", line 243, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
  File "/usr/local/lib/python3.6/shelve.py", line 227, in init
    Shelf.init(self, dbm.open(filename, flag), protocol, writeback)
  File "/usr/local/lib/python3.6/dbm/__init__.py", line 94, in open
    return mod.open(file, flag, mode)
AttributeError: module 'dbm.ndbm' has no attribute 'open'

Behavior is the same on python 3.6 and 3.7. Error is spontaneous.

----------
components: Library (Lib)
messages: 383229
nosy: gardener.willy
priority: normal
severity: normal
status: open
title: shelve module is not thread-safe during accessing different databases from different threads
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42667>
_______________________________________


More information about the New-bugs-announce mailing list