Hello,

I am trying to asynchronously open and read a large text 
file (20MB) into a GTK text buffer. I have been successful 
at opening and reading the whole file at once, which is not
elegant. 

Unfortunately, the problem arises when I try to open and 
read the file 4096 bytes at a time. Not only does the whole 
file fail to load into the GTK text buffer, gnomevfs also 
spits out the following message several times at the 
terminal:

(scribes:29700): libgnomevfs-WARNING **: Unknown job kind 9

Here is an excerpt of the troublesome code in question.

------------------------------------------------------------

# Basic File Information

file_info = gnomevfs.get_file_info(filename)
file_size = file_info.size
opt_size = file_info.io_block_size


# Perform some cleanups

def close_cb(*args):

        pass
        

# Insert Text into a GTK Buffer
        
def read_cb():

        txt_buffer.insert_at_cursor(buffer)

        
# Try to read files 4096 bytes at a time        
        
def open_cb():
        
        size = 0

        # Problem Area

        while size <= file_size:
                handle.read(opt_size, read_cb)
                size += opt_size
                
        handle.close(close_cb)
        
# Open a file asynchronously
        
gnomevfs.async.open(filename, open_cb)

------------------------------------------------------------

Any help, suggestion and schooling is appreciated. I spent 
the whole of yesterday trying to figure it out, before 
eventually giving in. :-(

Thanks
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to