Pyglobus change/bug fix
Ivan R. Judson
judson at mcs.anl.gov
Fri Apr 23 16:11:21 CDT 2004
Hey,
In io.py, GSIFile.read(self, size=0, waitForBytes=1):
waitForBytes is not a flag, but a quantity (according to globus_io_read.c),
which makes it possible to have the GSIFile have the same semantics as any
standard file by simply adding:
if waitForBytes == 1:
waitForBytes = size
As the first thing that is done in the method, it turns into:
def read(self, size=0,waitForBytes=1):
"""
Read size bytes, returning a string.
"""
if waitForBytes == 1:
waitForBytes = size
if self.readok == 0:
raise IOError, "File not open for reading"
if size == 0:
size = self.rbuf.get_size()
if waitForBytes > size:
raise RuntimeError, "waitForBytes is larger than buffer_size"
elif self.rbuf.get_size() < size:
del(self.rbuf)
self.rbuf = Buffer(size)
nbytes = self.sock.read(self.rbuf, size, waitForBytes)
if nbytes < 1:
return ""
return self.rbuf.as_string(nbytes)
This makes life a lot easier, and correctly represents what the underlying
globus call means.
Can this be added to cvs?
--Ivan
More information about the ag-dev
mailing list