473,388 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

shelve: writing out updates?!

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.
Jul 31 '05 #1
8 1551
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

Jul 31 '05 #2
On 30 Jul 2005 17:48:39 -0700, Paul Rubin <http://ph****@NOSPAM.invalid> 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
Jul 31 '05 #3
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
Jul 31 '05 #4
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

Jul 31 '05 #5
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 "documentation" category in the bug reporting template for
this purpose.
Jul 31 '05 #6
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().
Jul 31 '05 #7
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
Jul 31 '05 #8
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
Jul 31 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
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...
2
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...
0
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...
0
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...
0
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...
0
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...
3
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...
5
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.