doesn't read the whole file

R. David Murray rdmurray at
Sat Mar 21 06:54:02 CET 2009

Sreejith K <sreejithemk at> wrote:
> 					tf.writelines("Reading from Base File\n")
>*4096 + off%4096)
> 					bend = 4096-(off%4096)
> 					if length-bend <= 0: ## if only a part of a block is to be read
> (not till the end of the block)
> 						data =
> 						break
> 					data +=
> 					length -= bend
> 					off = 4096
> 				return data
> This is the filesystem class for files. Whenever a read occurs an
> instance is created and read function is called. In my example when
> accessing a file named 'mango.txt' it checks for mango.txt_snaps/snap1
> dirctory and open file '0' as self.snap. But the read() returns (i.e
> data) a small part....
> Almost all the code worked weird in this example. Apart from read(),
> the break and continue also works weird. When opening the file
> 'mango.txt' the following output is written by tf (an output file).
> Here METHOD is not NORMAL, self.snap_cnt is 1, blocks is [['0']]
> File initiating..
> File initiated..
> Read length: 4096 offset: 0
> Snapshot 0 opened..
> Snap read
> Partial read from snap
> Snapshot 0 opened..
> Block not in snap
> Reading from Base File
> See the weirdness of continue and break here ?(loop was supposed to
> loop only once as rev_snap_list contains 0 only)

I'm not going to look at all this code looks way too complicated
and in need of some serious refactoring :)

But a couple of on-point comments:

How do you know rev_snap_list contains only 0?  You didn't log it.

Same for the read.  How do you know the read didn't read the whole
file?  You didn't log it.

Both your statements might be true, but until you show the logging
output proving it, you don't _know_ that your assumptions are true.

R. David Murray 

More information about the Python-list mailing list