", line 1, in ", line 1, in ", line 1, in

gdbm error 22 when performing Python shelve open

704 views Asked by At

Doing a simple shelve.open will give the following error:


>>> shelve.open('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/shelve.py", line 243, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
  File "/usr/lib/python3.6/shelve.py", line 227, in __init__
    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
  File "/usr/lib/python3.6/dbm/__init__.py", line 94, in open
    return mod.open(file, flag, mode)
_gdbm.error: [Errno 22] Invalid argument

I've only come across one related search result to this issue: https://github.com/pydanny/cookiecutter-django/issues/1793#issuecomment-440406112

I got exactly the same error on a Vagrant dev environment. Celery uses dbm for persistent storage, which is built on top of the gdbm C library. Some testing has revealed that this works when creating or opening files on a native filesystem but not on a mounted filesystem.

I'm running this under a Vagrant Ubuntu box in MacOS so it makes sense. I have also run the same box under Windows 10 and this issue doesn't crop up. Any clues for a fix?

1

There are 1 answers

0
ISHAR On

I had the same issue and couldn't find any help online until I came across this post

https://github.com/we45/ThreatPlaybook/issues/11

creating a new virtual environment worked for me