durusmail: durus-users: FileStorage bug?
FileStorage bug?
2004-10-15
2004-10-15
2004-10-15
2004-10-15
2004-10-15
2004-10-15
2004-10-15
2004-10-15
2004-10-15
FileStorage bug?
Austine Jane
2004-10-15
>From: Neil Schemenauer 
>To: Austine Jane 
>CC: durus-users@mems-exchange.org
>Subject: Re: [Durus-users] FileStorage bug?
>Date: Fri, 15 Oct 2004 10:29:16 -0400
>
>On Fri, Oct 15, 2004 at 11:16:19PM +0900, Austine Jane wrote:
> > I am using PersistentList to hold instances of a subclass of Persistent.
> > The instance of PersistentList is attached as an item in root
>dictionary.
> >
> > Whether I am using FileStorage or ClientStorage, the system breaks when
> > there are more than a dozen of items in the PersistentList.
>
>Yikes.  Something is badly wrong.
>
> > Following tracebacks were made when I put in about twenty items in the
>list
> > and stopped the client and restarted the client(the durus server was
>still
> > running) to put another item. The error is reproducible and it happens
> > always.
> >
> > traceback 1:
> >
> > Traceback (most recent call last):
> >  File "c:\python23\Lib\site-packages\quixote\publish.py", line 522, in
> > process_request
> >    output = self.try_publish(request, env.get('PATH_INFO', ''))
> >  File "c:\python23\Lib\site-packages\quixote\publish.py", line 457, in
> > try_publish
> >    output = object(request)
> > [snip]
> >  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 108,
>in
> > __init__
> >    self._build_index()
> >  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 130,
>in
> > _build_index
> >    trecord = readn(self.fp, size)
> >  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 16, in
> > readn
> >    s = fp.read(n)
> > MemoryError
>
>Would it be possible for you to provide sample code to reproduce
>this problem?  We can try to run it on a Windows machine we have
>here.
>
>   Neil

Yes.
###############
import os
from durus.connection import Connection
from durus.file_storage import FileStorage
from durus.persistent import Persistent
from durus.persistent_list import PersistentList

FILENAME='broken.durus'

class People(PersistentList):
    def addPerson(self,name):
        self.append(Person(name))

class Person(Persistent):
    def __init__(self,name):
        self.name=name

def init(createDb):
    if createDb:
        try:
            os.unlink(FILENAME)
        except:
            pass
    s=FileStorage(FILENAME)
    #s=ClientStorage() #this fails as well
    c=Connection(s)
    root=c.get_root()
    if createDb:
        root['peopledb']=People()
        c.commit()
    return c,root['peopledb']

def putInSome(c,db):
    for i in range(20):
        db.addPerson(People())
        c.commit()

if __name__=='__main__':
    c,db=init(True)
    putInSome(c,db)
    c.storage.close() #to make the effect of restarting the client
    c,db=init(False)
    putInSome(c,db)

#########
Run the code and you will see the following traceback:

C:\test>broken.py
Traceback (most recent call last):
  File "C:\work\playground\broken.py", line 41, in ?
    c,db=init(False)
  File "C:\work\playground\broken.py", line 23, in init
    s=FileStorage(FILENAME)
  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 108, in
__init__
    self._build_index()
  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 130, in
_build_index
    trecord = readn(self.fp, size)
  File "C:\PYTHON23\lib\site-packages\durus\file_storage.py", line 19, in
readn
    raise IOError, 'short read'
IOError: short read

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.com/
reply