Shelve uses dbm and pickle to make a persistent object store. The
"db" in "dbm" stands for "database" and while I didn't expect full
ACID capability, I'd have thought there'd be at least some minimum
gesture towards durability of updates. But say that s is a shelve
object. If I say
s[whatever] = value
there is no way apparent from the shelve docs to get the update
flushed out to the disk file until the shelve is actually closed. If
I'm using the shelve to store stuff in a long-running server, it could
be months before the shelve closes.
Is shelve really missing this capability?
Thanks. 8 1570
Paul Rubin wrote: Shelve uses dbm and pickle to make a persistent object store. The "db" in "dbm" stands for "database" and while I didn't expect full ACID capability, I'd have thought there'd be at least some minimum gesture towards durability of updates. But say that s is a shelve object. If I say
s[whatever] = value
there is no way apparent from the shelve docs to get the update flushed out to the disk file until the shelve is actually closed. If I'm using the shelve to store stuff in a long-running server, it could be months before the shelve closes.
Is shelve really missing this capability?
No. Call the .sync() method. Unfortunately, the shelve module is not
well-documented.
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
On 30 Jul 2005 17:48:39 -0700, Paul Rubin <http://ph****@NOSPAM.i nvalid> wrote: Shelve uses dbm and pickle to make a persistent object store. The "db" in "dbm" stands for "database" and while I didn't expect full ACID capability,
What is ACID?
I'd have thought there'd be at least some minimum gesture towards durability of updates. But say that s is a shelve object. If I say
s[whatever] = value
there is no way apparent from the shelve docs to get the update flushed out to the disk file until the shelve is actually closed.
Wierd. I'd expect something like an s.flush() function.
--
Email: zen19725 at zen dot co dot uk
On Sat, 30 Jul 2005 17:57:17 -0700, Robert Kern <rk***@ucsd.edu > wrote: Paul Rubin wrote: Shelve uses dbm and pickle to make a persistent object store. The "db" in "dbm" stands for "database" and while I didn't expect full ACID capability, I'd have thought there'd be at least some minimum gesture towards durability of updates. But say that s is a shelve object. If I say
s[whatever] = value
there is no way apparent from the shelve docs to get the update flushed out to the disk file until the shelve is actually closed. If I'm using the shelve to store stuff in a long-running server, it could be months before the shelve closes.
Is shelve really missing this capability?
No. Call the .sync() method. Unfortunately, the shelve module is not well-documented.
Obviously it's good when stuff is well documented.
I wonder if the barrier to good documentation is set too high?
If i wanted to add some documentation here, I'd have to download the
current source for the latest Python documentation, download,
install and learn the code that processes the source documentation,
write my changes then send the results into the CVS. (I'm assuming
that's roughly correct -- I haven't actually done it).
The point is, that would be a major effort, too major to merely add
a few lines detailing the .sync method.
But, what if the Python documentation was on a Wiki? Then it would
be easy to update! Of course, we would have to guard against false
or malicious updates, but Wikipedia manage that OK. The
Documentation Wiki could then be used as a basis for the "official"
documentation that comes with each new release.
Does this idea make some sense? Or are there hidden pitfalls?
--
Email: zen19725 at zen dot co dot uk
phil hunt wrote: Obviously it's good when stuff is well documented.
I wonder if the barrier to good documentation is set too high? If i wanted to add some documentation here, I'd have to download the current source for the latest Python documentation, download, install and learn the code that processes the source documentation, write my changes then send the results into the CVS. (I'm assuming that's roughly correct -- I haven't actually done it).
No, write the content in a reasonable format (i.e. plain text), post it
to the bug tracker, assign it to Fred Drake (I think), and he'll put it
in the right format. If it's longer documentation, like for a full
module, then it's better to actually learn the LaTeX so it can be
dropped in as is.
The point is, that would be a major effort, too major to merely add a few lines detailing the .sync method.
But, what if the Python documentation was on a Wiki? Then it would be easy to update! Of course, we would have to guard against false or malicious updates, but Wikipedia manage that OK.
That's a debatable assertion, but I don't think we'll have the same
problems of Wikipedia thanks to the apolitical nature of Python
documentation.
The Documentation Wiki could then be used as a basis for the "official" documentation that comes with each new release.
Does this idea make some sense? Or are there hidden pitfalls?
Yes! Someone actually has to do it! The same idea has come up time and
time again. It's still not here because no one has been able to commit
to the effort involved.
--
Robert Kern rk***@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter ze******@zen.co .uk (phil hunt) writes: No. Call the .sync() method. Unfortunately, the shelve module is not well-documented.
Obviously it's good when stuff is well documented.
I wonder if the barrier to good documentation is set too high? If i wanted to add some documentation here, ...
I entered a sourceforge bug asking that the doc be updated (thanks,
Robert!). I've done that several times before for similar small doc
bugs and they've always been taken care of reasonably quickly.
There's a "documentat ion" category in the bug reporting template for
this purpose. ze******@zen.co .uk (phil hunt) writes: What is ACID?
Basically it means full-blown a transactional database that handles
concurrent updates correctly. See: http://en.wikipedia.org/wiki/ACID
Wierd. I'd expect something like an s.flush() function.
Thanks to Robert Kern for pointing out that the answer is s.sync().
phil hunt wrote: But, what if the Python documentation was on a Wiki? Then it would be easy to update! Of course, we would have to guard against false or malicious updates, but Wikipedia manage that OK. The Documentation Wiki could then be used as a basis for the "official" documentation that comes with each new release.
Does this idea make some sense? Or are there hidden pitfalls?
I thought the `Annotatable Python Docs`_ were a good idea but they seem
to have fallen into disuse.
... _Annotatable Python Docs: http://pydoc.amk.ca/frame.html
--
Michael Hoffman
Robert Kern <rk***@ucsd.edu > writes: The Documentation Wiki could then be used as a basis for the "official" documentation that comes with each new release. Does this idea make some sense? Or are there hidden pitfalls?
Yes! Someone actually has to do it!
I think someone is working on this as part of the summer of code
program (but am not sure about that...).
Cheers,
mwh
--
QNX... the OS that walks like a duck, quacks like a duck, but is,
in fact, a platypus. ... the adventures of porting duck software
to the platypus were avoidable this time. -- Chris Klein, asr This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rami A. Kishek |
last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I
hope someone here can shed some light. First of all, I have this piece
of code which uses shelve to save instances of some class I define. It
works perfectly on an old machine (PII-400) running Python 2.2.1 under
RedHat Linux 8.0. When I try to run it under Python for windows ME on a
P-4 1.4 GHz, however, it keeps crashing on reading from the shelved file
the second...
|
by: AK |
last post by:
Hello,
I'm using shelve module in python 2.3 and I found that it does a very
odd thing, at least very unexpected to me. It seems that the data of a
replaced or deleted key stays in filename.dat file.
Example:
>>> d = *1000
>>> from shelve import *
|
by: seth |
last post by:
Last week I encountered an AttributeError in my unit tests that I
wasn'table to catch with an "except AttributeError" statement.
The problem stemmed from a class that raised an error inside
__init__and defined a __del__ method to clean up resources. I then
discovered asimilar problem in the shelve module. This led me to two
importantdiscoveries:
1. Attributes defined in __init__ after an error is raised will not be
apart of the...
|
by: Blair Hall |
last post by:
I am having trouble understanding the correct use of 'shelve'.
I have a number of small programs that read and write to a single
shelve file (not multithreading though).
It seems that by writing to an existing entry I
sometimes corrupt the database. For instance, I get the problem
when a Python script has opened the file and read and written a few
objects it then tries to overwrite an existing entry:
|
by: Nicholas Wieland |
last post by:
I'm using the shelve module for a program I'm writing, and reading the
source I've noted that shelve doesn't use new style classes.
Well, this is the first time I use *seriously* new style classes (I work
primarly on Zope and Python 2.1), so the result is probably far from
production code, but after half an hour of hacking my Shelf class seems to
work like the original one (much more than what I expected...) :)
class Shelf (dict):
def...
| |
by: Michele Simionato |
last post by:
The standard library says:
"""
The shelve module does not support concurrent read/write access to
shelved objects. (Multiple simultaneous read accesses are safe.) When a
program has a shelf open for writing, no other program should have it
open for reading or writing.
"""
But what about threads? If a single program open a shelve and many
threads
|
by: Michele Petrazzo |
last post by:
Hi,
I'm trying a script on a debian 3.1 that has problems on shelve library.
The same script work well on a fedora 2 and I don't know why it create
this problem on debian:
#extract from my code
import shelve
class XX:
def __init__(self):
self._data = shelve.open("/tmp/myfile")
|
by: gluckj |
last post by:
Hi,
I'm not a Win ME fan myself (I'm a Mac user), but I'm here in Thailand
developing software for special-needs kids, and the test PC in my home
office is a Win ME machine (sigh). So when I ported my Python program
today to the PC, it quickly crashed. Everything seems to work except
for shelve. Using the latest version of Python (2.5.1), when I do the
following in IDLE on the Win ME machine here's the result:
Python 2.5.1...
|
by: bluesmanu |
last post by:
Hi all,
I am trying to use the shelve module to save an object of a 'Electron'
class I made into a file. The writing goes well but the reading goes :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "shelve.py", line 113, in __getitem__
value = Unpickler(f).load()
AttributeError: 'module' object has no attribute 'Electron'
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |