file.read() doesn't read the whole file
sreejithemk at gmail.com
Fri Mar 20 07:36:46 CET 2009
>>> snapdir = './mango.txt_snaps'
>>> snap_cnt = 1
>>> block = 0
>>> import os
>>> snap = open(snapdir + '/snap%s/%s' % (repr(snap_cnt), repr(block)),'r')
>>> snapdir + '/snap%s/%s' % (repr(snap_cnt), repr(block))
The above code works fine and it reads the whole file till EOF. But
when this method is used in a different scenario the file is not read
completely. I'll post the code that read only some part of the file...
self.snap = open(self.snapdir + '/snap%d/%d' % (self.snap_cnt,
block),'r') ## opens /mnt/gfs_local/mango.txt_snaps/snap1/0
self.snap.seek(off%4096) ## seeks to 0 in this case
bend = 4096-(off%4096) ## 4096 in this case
if length-bend <= 0: ## true in this case as length is 4096
data = self.snap.read(length)
the output data is supposed to read the whole fie but it only reads a
part of it. Why is it encountering an early EOF ?
More information about the Python-list