shelve

Is there a maximum size for python's shelve module?

不想你离开。 提交于 2019-12-12 14:13:39
问题 I'm getting this exception when trying to open shelve persisted files over a certain size which is actually pretty small (< 1MB) but I'm not sure where the exactly number is. Now, I know pickle is sort of the bastard child of python and shelve isn't thought of as a particularly robust solution, but it happens to solve my problem wonderfully (in theory) and I haven't been able to find a reason for this exception. Traceback (most recent call last): File "test_shelve.py", line 27, in <module>

module object has no attribute open in shelve [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-12 04:54:36
问题 This question already has answers here : Importing installed package from script raises “AttributeError: module has no attribute” or “ImportError: cannot import name” (2 answers) Closed 2 months ago . Following is my code, import shelve sd = shelve.open("session.data") When I try the same code in IDLE , I am not getting any error. But when running the script with this code, I am getting the following error, Traceback (most recent call last): File "try.py", line 3, in <module> sd = shelve.open

Got gdbm error: (13, 'Permission denied') — Despite posix permissions seeming OK

房东的猫 提交于 2019-12-11 05:53:20
问题 I'm working with shelve in python 2.7.6 for caching calculations, and I've ran into the issue described HERE for shelve files produced by me and implemented the suggested solution in a function that merges a file other into the file target : ... # target and other are strings # Loads the gdbm module, as suggested mod = __import__("gdbm") # Open target for modifications tar = shelve.Shelf(mod.open(target, 'c', 0666)) # THROWS EXCEPTION # Open other for reading oth = shelve.Shelf(mod.open(other

Visual Studio 2008 TFS Shelve/Unshelve changes stopped working and hangs VS

时间秒杀一切 提交于 2019-12-11 00:48:39
问题 Greetings. This is second time I've actually spotted this problem with VS 2008 TS with TFS addon installed on top. The problem is that at some point, when you actively work with Shelve/Unshelve changes from TFS, the Shelve changes window (when you hit "Shelve" button) hangs and hangs whole VS. After that, if you restart studio, the Shelve/Unshelve window just stops working. Any attempt to call for Shelve/Unshelve window hangs Studio completely. Therefore, Shelving becomes unusable, but I

Prevent python shelve corruption

穿精又带淫゛_ 提交于 2019-12-10 17:25:07
问题 How should I prevent corruption in a shelve file? Should the shelve be closed most of the time and then opened only when I need to read or edit a value? 回答1: If safety of your persistent objects is of high importance in your project, using shelve is not a good idea. Neither is pickling objects and manually writing them into files. Consider that real databases invest huge resources (brainpower and code) to be safe in case of failures. So keep your data in a real DB. The simplest would be

Mercurial - Working with Queues similar to Shelves?

ぐ巨炮叔叔 提交于 2019-12-09 14:40:48
问题 I've recently started working with MQ as I like the idea of working on isolated patches and committing without affecting the repo until the changeset is refined enough. Before that, I used to work with Mercurial's shelves extension, but found it a bit unstable. What I'm still trying to figure out in MQ is how to keep patches separate from each other and apply them in no particular order, and across different branches. Here's my normal flow - 1. Start working on a new patch: hg qnew fix-bug

Python 2.7.2 shelve fails on OSX

别说谁变了你拦得住时间么 提交于 2019-12-08 20:05:31
Using the shelve standard lib on Python 2.7.2, I wrote an extremely simple test to create a persistent data file and then immediately open it for printing: import os import shelve shelf_filename = str(__file__.split('.')[0] + '.dat') #delete the shelf file if it exists already. try: os.remove(shelf_filename) print "DELETED LEFTOVER SHELF FILE", shelf_filename except OSError: pass #create a new shelf, write some data, and flush it to disk shelf_handle = shelve.open(shelf_filename) print "OPENED", shelf_filename, "WITH SHELF" shelf_handle['foo'] = 'bar' shelf_handle.close() print "FLUSHED AND

Accessing Dictionaries VS Accessing Shelves

家住魔仙堡 提交于 2019-12-07 07:53:28
Currently, I have a dictionary that has a number as the key and a Class as a value. I can access the attributes of that Class like so: dictionary[str(instantiated_class_id_number)].attribute1 Due to memory issues, I want to use the shelve module. I am wondering if doing so is plausible. Does a shelve dictionary act the exact same as a standard dictionary? If not, how does it differ? Shelve doesn't act extactly the same as dictionary, notably when modifying objects that are already in the dictionary. The difference is that when you add a class to a dictionary a reference is stored, but shelve

Python shelve having items that aren't listed

。_饼干妹妹 提交于 2019-12-07 04:29:08
问题 I've been saving a bunch of dictionaries to file using Python's shelve module (with Python 3.4 on OSX 10.9.5). Each key is a string of an int (e.g., "84554" ), and each value is a dictionary of dictionaries of a few smallish strings. No keys are used twice, and I know the total superset of all possible keys. I am adding these key-value pairs to the shelf via threads and which keys/values are added changes each time I run it (which is expected). The problem I've been having is that the number

How to keep uncommitted changes in a local mercurial repository, while still pushing/pulling?

放肆的年华 提交于 2019-12-07 03:22:25
问题 If i'm working on some files that I don't want to commit, I just save them. I then have other files I want to push to the server, however if someone else has made changes to the repository, and I pull them down, it asks me to merge or rebase.. but either of these options will cause me to lose my local changes that I have not committed . What are other people doing to get around this? I find the documentation for the shelving extension hard to get my head around. Note: I'm using Mercurial