Questions tagged [shelve]

Shelve can refer to either a Python object persistence or a pending change in a Visual Studio Workspace

A shelf in Python is a persistent, dictionary-like object. Documentation: shelve

Shelve can also refer to a pending change in the workspace within Visual Studio 2005

351 questions
2
votes
0 answers

Python shelve leak?

It seems that when overwriting a key in a shelve, under certain circumstances the shelve size unexpectedly keeps growing larger. It is as if some data in a shelve ends up not having a reference to it, like in a memory leak. It seems to have…
rinspy
  • 386
  • 1
  • 10
2
votes
1 answer

Understanding the sync method from the python shelve library

The python documentation says this about the sync method: Write back all entries in the cache if the shelf was opened with writeback set to True. Also empty the cache and synchronize the persistent dictionary on disk, if feasible. This is…
ashir
  • 111
  • 7
2
votes
1 answer

using pathlib to open shelved files in python

I use pathlib to open textfiles that exists in a different directory, but get this error TypeError:`"Unsupported operand type for +:'WindowsPath' and 'str'" when I try opening a shelved file that exist in a score folder in the current directory…
Chiebukar
  • 83
  • 9
2
votes
0 answers

Python: Pass Readonly Shelve to subprocesses

As discussed here: Python: Multiprocessing on Windows -> Shared Readonly Memory I have a heavily parallelized task. Multiple workers do some stuff and in the end need to access some keys of a dictionary which contains several millions of key:value…
tim
  • 9,896
  • 20
  • 81
  • 137
2
votes
1 answer

gdbm error 22 when performing Python shelve open

Doing a simple shelve.open will give the following error: >>> shelve.open('foo') Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.6/shelve.py", line 243, in open return DbfilenameShelf(filename,…
Helen Che
  • 1,951
  • 5
  • 29
  • 41
2
votes
3 answers

How to fix "list indices must be integers or slices" error

I'm making a program that should save your ip address to a list in a separate file using shelve. Each time it is opened it should put the the ip address in list "pubipcount" in list "pubiplist". When I go to add a new ip I get an error that I don't…
Secksee
  • 25
  • 3
2
votes
3 answers

Very basic persistence or data storage for a Python script

I have a script which processes a list of URLs. The script may be called at any time with a fresh list of URLs. I want to avoid processing an URL which has already been processed at any time in the past. At this point, all I want to match are URLs,…
Pranab
  • 2,207
  • 5
  • 30
  • 50
2
votes
1 answer

KeyError and AtrributeError when trying to retrieve a shelved class - Python 3.6

When serializing a class in one program(with shelve), I cannot retrieve it without getting the follow error: File "\Python36_64\lib\shelve.py", line 111, in __getitem__ value = self.cache[key] KeyError: 'foo' During handling of the above…
DapperEmu
  • 25
  • 4
2
votes
2 answers

Resource temporarily unavailable on Python shelve.open

I have a Python application that does the following: Is called by another process/processes once every 2-3 minutes in order to store an object using with shelve.open(shelvefilename, flag='c'). Is called by another process/processes many times per…
trikelef
  • 2,192
  • 1
  • 22
  • 39
2
votes
1 answer

Know when a shelved changelist's content was last modified

In our CI flow, we accept a shelved changelist and run the tests against it. In order to avoid users changing the content of the changelist during the compilation/tests, we duplicate the changelist and run all tests on the copy + submit the copied…
eran be
  • 45
  • 5
2
votes
1 answer

Python shelve able to create but not open shelf

I'm having a strange experience. I'm running python3.5.3 on debian, installed through the official repositories. I have a few objects that I store in a shelf as follows with shelve.open(filename,'c') as shelf: shelf['lists'] = (bus1,bus2) …
user128063
  • 203
  • 1
  • 6
2
votes
2 answers

How to remove reverted file from swarm review

I created swarm review, then decided to revert some changes, so deleted files from corresponding CL. But files are still in swarm. There are two types of such files: Files existed before i made my changes and i reverted it. Files created during my…
Yola
  • 18,496
  • 11
  • 65
  • 106
2
votes
1 answer

shelve module does not work with "with" statement

I'm trying to use the shelve module in python, and I'm trying to combine it with the "with" statement, but when trying to do that I get the following error: with shelve.open('shelve', 'c') as shlv_file: shlv_file['title'] = 'The main title of…
Pj-
  • 430
  • 4
  • 14
2
votes
1 answer

Iterate/Loop over Shelve

How would one iterate the contents of a Shelve? import Shelve testShelve = Shelve.open("testShelve") testShelve["key"] = "value" for k in testShelve.keys(): print(k)
jneidel
  • 41
  • 6
2
votes
0 answers

Use python multiprocessing queue to write to a shelve file

I met a problem with python multiprocessing. I have a .csv file (~ 10 GB). I want to read data from it, transform the data and then save it into a python shelve file. The data transformation is quite slow, so I am thinking about multiprocessing. I…