[ZODB-Dev] How to move fs files between directories?
Ammar Hakim
ammarhakim777 at yahoo.com
Sun Jan 23 14:46:15 EST 2005
Hello Tim,
Thanks for the reply. The problem was that effectively
the database was being opened twice with write access.
Using a singleton to hold the open database connection
solved the problem.
Cheers,
Ammar
--- Tim Peters <tim at zope.com> wrote:
> [Ammar Hakim]
> > I just started using ZODB a couple of days ago. I
> converted an
> > application using SQLITE to now use ZODB.
> Everything works great!
>
> To keep it that way <wink>, do read this:
>
> http://zope.org/Wikis/ZODB/FileStorageBackup
>
> > The problem I have is that I am not able to copy
> the fs file to some
> > other location on the same machine. If I do so and
> try to open it,
>
> Sorry, I'm confused already. You first said you
> weren't able to copy it.
> But if that's true, how could you possibly try to
> open the copy (that you
> weren't able to make)? I'll assume that you were in
> fact able to copy it,
> and that the "it" in "and try to open it" refers to
> the copy, not to the
> original.
>
> > say from the python prompt, I get the execption
> IOError: [Errno 11]
> > Resource temporarily unavailable.
>
> It's a Unix file-locking thing. I don't really
> understand that stuff
> anymore (it's been a long time). In general, ZODB
> wants at most one handle
> with read access to a FileStorage open at a time.
> But then if my
> assumptions above are correct, I don't see any
> reason for the complaint
> you're seeing.
>
> Can you back up and be more specific about exactly
> what it is you typed at
> your command prompt, from the attempt to copy
> onward?
>
> > Is there some special way to copy the fs file
>
> No, although read the page linked to above.
>
> > or does the database need to be closed in a
> special way when the
> > application shuts down?
>
> You should close the database when you're done with
> it, via invoking its
> .close() method.
>
> > I am attaching a stack trace below.
>
> That would be a lot more helpful if you also
> explained exactly what it is
> you did preceding this stack trace.
>
> > Cheers, Ammar
> >
> > File
> > "/usr/lib/python2.3/site-packages/ZODB/config.py",
> line 52, in
> > databaseFromURL
> > return databaseFromConfig(config.database)
> > File
> > "/usr/lib/python2.3/site-packages/ZODB/config.py",
> line 55, in
> > databaseFromConfig
> > return section.open()
> > File
> > "/usr/lib/python2.3/site-packages/ZODB/config.py",
> line 97, in open
> > storage = section.storage.open()
> > File
> > "/usr/lib/python2.3/site-packages/ZODB/config.py",
> line 133, in open
> > quota=self.config.quota)
> > File
> >
>
"/usr/lib/python2.3/site-packages/ZODB/FileStorage/FileStorage.py",
> line
> > 120, in __init__
> > self._lock_file = LockFile(file_name +
> '.lock')
> > File
> >
>
"/usr/lib/python2.3/site-packages/ZODB/lock_file.py",
> line 63, in
> > __init__
> > lock_file(self._fp)
> > File
> >
>
"/usr/lib/python2.3/site-packages/ZODB/lock_file.py",
> line 42, in
> > lock_file
> > fcntl.flock(file.fileno(), _flags)
> > IOError: [Errno 11] Resource temporarily
> unavailable
>
> That's the expected exception on a Unixish box if
> more than one attempt to
> open the database file for write access is made
> simultaneously. For
> example,
>
> $ python
> Python 2.3.4 (#1, Aug 9 2004, 17:15:36)
> [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on
> linux2
> Type "help", "copyright", "credits" or "license" for
> more information.
> >>> import ZODB
> >>> ZODB.__version__
> '3.2.5'
> >>> from ZODB.FileStorage import FileStorage
> >>> st1 = FileStorage('Data.fs')
> >>> st2 = FileStorage('Data.fs') # and try opening
> it again -- boom!
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "ZODB/FileStorage.py", line 232, in __init__
> self._lock_file = LockFile(file_name + '.lock')
> File "ZODB/lock_file.py", line 62, in __init__
> lock_file(self._fp)
> File "ZODB/lock_file.py", line 42, in lock_file
> fcntl.flock(file.fileno(), _flags)
> IOError: [Errno 11] Resource temporarily unavailable
> >>> st3 = FileStorage('Data.fs', read_only=True) #
> but read_only is fine
>
>
>
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
More information about the ZODB-Dev
mailing list