Hi,
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to hard to track down database corruption errors.
Amir 15 3740
27 Aug 2006 00:44:33 -0700, Amir Michail <am******@gmail .com>:
Hi,
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to hard to track down database corruption errors.
Amir
-- http://mail.python.org/mailman/listinfo/python-list
Even if it could be strange, the OS usually allow you to open a file
twice, that's up to the programmer to ensure the consistency of the
operations.
PAolo
--
if you have a minute to spend please visit my photogrphy site: http://mypic.co.nr
Paolo Pantaleo wrote:
27 Aug 2006 00:44:33 -0700, Amir Michail <am******@gmail .com>:
Hi,
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to hard to track down database corruption errors.
Amir
-- http://mail.python.org/mailman/listinfo/python-list
Even if it could be strange, the OS usually allow you to open a file
twice, that's up to the programmer to ensure the consistency of the
operations.
PAolo
But if this is usually a serious bug, shouldn't an exception be raised?
Amir
>
--
if you have a minute to spend please visit my photogrphy site: http://mypic.co.nr
Amir Michail schrieb:
Paolo Pantaleo wrote:
>27 Aug 2006 00:44:33 -0700, Amir Michail <am******@gmail .com>:
>>Hi,
Trying to open a file for writing that is already open for writing should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and this can lead to hard to track down database corruption errors.
Amir
-- http://mail.python.org/mailman/listinfo/python-list
Even if it could be strange, the OS usually allow you to open a file twice, that's up to the programmer to ensure the consistency of the operations.
PAolo
But if this is usually a serious bug, shouldn't an exception be raised?
executing "rm -rf /" via subprocess is usually also a bad idea. So? No
language can prevent you from doing such mistake. And there is no way to
know if a file is opened twice - it might that you open the same file
twice via e.g. a network share. No way to know that it is the same file.
Diez
Amir Michail wrote:
Hi,
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to hard to track down database corruption errors.
Amir
I've never done this in anger so feel free to mock (a little :-).
I'd have a fixed field at the beginning of the field that can hold the
hostname process number, and access time of a writing process, togeher
with a sentinal value that means "no process has access to the file".
A program would:
1. wait a random time.
2. open for update the file
3. read the locking data
4. If it is already being used by another process then goto 1.
5. write the process's locking data and time into the lock field.
6 Modify the files other fields.
7 write the sentinal value to the locking field.
8. Close and flush the file to disk.
I have left what to do if a process has locked the file for too long as
a simple exercise for you ;-).
- Paddy.
Diez B. Roggisch wrote:
Amir Michail schrieb:
Paolo Pantaleo wrote:
27 Aug 2006 00:44:33 -0700, Amir Michail <am******@gmail .com>: Hi,
Trying to open a file for writing that is already open for writing should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and this can lead to hard to track down database corruption errors.
Amir
-- http://mail.python.org/mailman/listinfo/python-list
Even if it could be strange, the OS usually allow you to open a file
twice, that's up to the programmer to ensure the consistency of the
operations.
PAolo
But if this is usually a serious bug, shouldn't an exception be raised?
executing "rm -rf /" via subprocess is usually also a bad idea. So? No
language can prevent you from doing such mistake. And there is no way to
know if a file is opened twice - it might that you open the same file
twice via e.g. a network share. No way to know that it is the same file.
Diez
The scenario I have in mind is something like this:
def f():
db=shelve.open( 'test.db', 'c')
# do some stuff with db
g()
db.close()
def g():
db=shelve.open( 'test.db', 'c')
# do some stuff with db
db.close()
I think it would be easy for python to check for this problem in
scenarios like this.
Amir
Amir Michail schrieb:
Diez B. Roggisch wrote:
>Amir Michail schrieb:
>>Paolo Pantaleo wrote: 27 Aug 2006 00:44:33 -0700, Amir Michail <am******@gmail .com>: Hi, > Trying to open a file for writing that is already open for writing should result in an exception. > It's all too easy to accidentally open a shelve for writing twice and this can lead to hard to track down database corruption errors. > Amir > -- http://mail.python.org/mailman/listinfo/python-list > Even if it could be strange, the OS usually allow you to open a file twice, that's up to the programmer to ensure the consistency of the operations .
PAolo
But if this is usually a serious bug, shouldn't an exception be raised?
executing "rm -rf /" via subprocess is usually also a bad idea. So? No language can prevent you from doing such mistake. And there is no way to know if a file is opened twice - it might that you open the same file twice via e.g. a network share. No way to know that it is the same file.
Diez
The scenario I have in mind is something like this:
def f():
db=shelve.open( 'test.db', 'c')
# do some stuff with db
g()
db.close()
def g():
db=shelve.open( 'test.db', 'c')
# do some stuff with db
db.close()
I think it would be easy for python to check for this problem in
scenarios like this.
You are requesting a general solution for a very particular problem. As
I pointed out, that solution is unlikely to work reliably - if not
infeasible at all.
If you really have problems as the above, use a custom wrapper for
shelve that prevents _you_ from making that mistake.
Diez
Amir Michail wrote:
Trying to open a file for writing that is already open for writing
should result in an exception.
It's all too easy to accidentally open a shelve for writing twice and
this can lead to hard to track down database corruption errors.
The right solution is file locking. Unfortunately, the Python
tandard distribution doesn't have a portable file lock, but you
can do it on Unix and Win NT or better. See: http://mail.python.org/pipermail/pyt...ry/002957.html
and/or http://aspn.activestate.com/ASPN/Coo...n/Recipe/65203.
--
--Bryan
On 2006-08-27, Amir Michail <am******@gmail .comwrote:
Trying to open a file for writing that is already open for writing
should result in an exception.
MS Windows seems to do something similar, and it pisses me off
no end. Trying to open a file and read it while somebody else
has it open for writing causes an exception. If I want to open
a file and read it while it's being writtent to, that's my
business.
Likewise, if I want to have a file open for writing twice,
that's my business as well. I certainly don't want to be
hobbled to prevent me from wandering off in the wrong direction.
It's all too easy to accidentally open a shelve for writing
twice and this can lead to hard to track down database
corruption errors.
It's all to easy to delete the wrong element from a list. It's
all to easy to re-bind the wrong object to a name. Should
lists be immutable and names be permanently bound?
--
Grant Edwards grante Yow! I'm in a twist
at contest!! I'm in a
visi.com bathtub! It's on Mars!! I'm
in tip-top condition!
Grant Edwards wrote:
On 2006-08-27, Amir Michail <am******@gmail .comwrote:
Trying to open a file for writing that is already open for writing
should result in an exception.
MS Windows seems to do something similar, and it pisses me off
no end. Trying to open a file and read it while somebody else
has it open for writing causes an exception. If I want to open
a file and read it while it's being writtent to, that's my
business.
Likewise, if I want to have a file open for writing twice,
that's my business as well. I certainly don't want to be
hobbled to prevent me from wandering off in the wrong direction.
It's all too easy to accidentally open a shelve for writing
twice and this can lead to hard to track down database
corruption errors.
It's all to easy to delete the wrong element from a list. It's
all to easy to re-bind the wrong object to a name. Should
lists be immutable and names be permanently bound?
How often do you need to open a file multiple times for writing?
As a high-level language, Python should prevent people from corrupting
data as much as possible.
Amir
--
Grant Edwards grante Yow! I'm in a twist
at contest!! I'm in a
visi.com bathtub! It's on Mars!! I'm
in tip-top condition!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Riley DeWiley |
last post by:
I have a project that is using a Jet backend and having trouble with Jet's
tendency to bloat it's MDB file. I can compact it but it is a hassle. I am
considering switching to a Fox backend but have not used one. I want to
know:
1) Does the Foxpro backend also bloat like this?
2) Is it hard to distribute fox binaries if all you want is bare bones DBMS
stuff (I handle all the UI)?
RDeW
|
by: Bob Darlington |
last post by:
I have a repair and backup database routine which runs when a user closes
down my application.
It works fine in my development machine, but breaks on a client's at the
following line:
If Dir(strLDB) <> "" Then Kill (strLDB)
where strLDB is the path to the ldb file.
The client advises that the ldb doesn't lurk after the program closes.
Any ideas?
|
by: ranjeet.gupta |
last post by:
Dear All
Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?
In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.
Juts Theoritical Assumtion below:
|
by: nepdae |
last post by:
Please forgive me, this is a long one.
My 11-user Access 2000 database is having recurring corruption
problems. The symptoms include the following:
1) corrupted fields in recently created or accessed records
2) incorrectly linked records via primary and foreign keys (looking at
the tables displays the correct key number but when filtered it links
to a different number).
3) truncating of text entered in a memo field
|
by: shineofleo |
last post by:
Here is the situation: I wrote a VB programm, which stores all the
information in a single Access database file using jet engine. It
worked well, however one of my customs reported that there was some
problems with this programm. I checked, the log files showed that the
database was corrupted.
The customer told me that there no 'illegal' operation such as pull out
the plug, or kill the programm via task manager...
So is there any...
| |
by: robert.waters |
last post by:
Hello,
I have been experiencing crashes and code corruption in my project
(vbe6.dll; a decompile fixes the corruption); for the life of me I
cannot figure out why, and I can't pin down the offending code because
each crash immediately shuts down the database and forces me to
recompile in order to open it again. I am following proper coding
procedures, e.g. creating and destroying objects properly (AFAIK),
closing adodb recordsets...
|
by: rdemyan via AccessMonster.com |
last post by:
I'm writing code to backup the back-end file from my front-end. The code will
automatically run the routine when the main app is closed and when certain
critieria are met.
The question is: What are those criteria??
I've seen a number of posts and experienced it myself that compacting can
occassionally cause corruption. So I don't want to compact unnecessarily.
My thinking is as follows:
|
by: Wayne |
last post by:
I have an Access 2003 data file that has now corrupted twice in a
week. The database is extremely simple with one main data table and a
few lookup tables. The lookup tables are linked to the main table via
relationships. Each user has their own copy of the frontend which
links back to the data file on the server.
The corrupted data file repairs OK but on both occasions 2
relationships have disappeared in the Relationships Window. When...
|
by: Martincruise |
last post by:
I face the below error message, when I attempt to mount an Access database
"Microsoft Access has detected corruption in this file. To try to repair the corruption, first make a backup copy of the file. Then, on the Tools menu, point to Database Utilities and click Compact and Repair Database. If you are currently trying to repair this corruption then you will need to recreate this file or restore it from a previous backup."
What can I do...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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.
| |