Package pyGlobus :: Module io :: Class IOBase
[show private | hide private]
[frames | no frames]

Class IOBase

Known Subclasses:
GSITCPSocket

Method Summary
  __init__(self, handle)
Constructs a IOBase class instance, using the given handle.
  __del__(self)
  cancel(self, doCallbacks)
Cancel any outstanding operation registered to this IOBase.
  close(self)
Close the handle associated with this IOBase.
  free_callback(self, cbHandle)
######################################################################### # Free's the underlying memory allocated for the callback structure.
  get_handle(self)
######################################################################## # XXX This handle is only valid as long as this object exists.
  read(self, buffer, maxBytes, waitForBytes)
Blocking TCP or file read
  register_close(self, callback, arg)
Asynchronously close the file or connection.
  register_read(self, buffer, maxBytes, waitForBytes, callback, arg)
Asynchronous TCP or file read.
  register_write(self, data, dataLen, callback, arg)
Asynchronous TCP or file write.
  try_read(self, buffer, maxBytes)
Nonblocking TCP or file read
  try_write(self, data, maxLen)
Nonblocking TCP or file write
  write(self, data, dataLen)
Blocking TCP or file write.

Method Details

__init__(self, handle)
(Constructor)

Constructs a IOBase class instance, using the given handle.
Parameters:
handle - the handle to be used in IOBase construction.

cancel(self, doCallbacks)

Cancel any outstanding operation registered to this IOBase.
Parameters:
doCallbacks - - If this parameter is set to True, then this function will block until all outstanding callbacks for this handle have been invoked and either completed or reached their conversion point. Otherwise, this will unregister any pending callbacks, and they will not be called.
Returns:
None
Raises:
IOBaseException -

A IOBaseException if cancel did not succeed or if the handle was not set properly.

Cancel may succeed without cancelling anything, or causing any callbacks to be invoked. There currently is no way to cancel specific registered callbacks without cancelling every registered operation.

close(self)

Close the handle associated with this IOBase.

free_callback(self, cbHandle)

######################################################################### # Free's the underlying memory allocated for the callback structure. #########################################################################

get_handle(self)

######################################################################## # XXX This handle is only valid as long as this object exists. When # the object is destroyed, the memory this handle points to is freed. #######################################################################

read(self, buffer, maxBytes, waitForBytes)

Blocking TCP or file read

Perform a blocking read on the handle. This will block until buf is filled with at least wait_for_nbytes and at most max_nbytes of data from handle, or end-of-file is reached.
Parameters:
buffer - The buffer to read data into.
maxBytes - The maximum number of bytes which can be read.
waitForBytes - The minimum number of bytes to read before returning.
Returns:
Returns number of bytes read.
Raises:
IOBaseException - A IOBaseException if one of these internal events occurred: The handle or nbytes_read parameter was equal to GLOBUS_NULL, so the registration could not be processed. The handle parameter was not initialized or ready, so the read registration could not be processed. The handle parameter was already registered for closing, so no more registrations can occur on this handle. The handle parameter was already registered for reading. The type of handle passed to the function by the handle parameter is not one of the types which supports the read operation.

register_close(self, callback, arg)

Asynchronously close the file or connection.

When this function returns successfully, no further operations may be done on this handle. Any outstanding requests on this handle with be cancelled with their callbacks invoked before the close completes.

No other callbacks may be registered with the globus_io system for this handle after this function is called. Close registrations may not be canceled.
Parameters:
callback - The callback function is called after all of the cancelled callbacks have been dispatched and have reached their thread conversion point or completed
arg - Parameter passed to the callback function.
Returns:
A SWIG'ized pointer to the callback handle is returned. After the callback completes, this may be free'd with the free_callback method, or it will be free'd when the instance is destroyed.
Raises:
IOBaseException - A IOBaseException

register_read(self, buffer, maxBytes, waitForBytes, callback, arg)

Asynchronous TCP or file read.
Parameters:
buffer - The buffer to read data into.
maxBytes - The maximum number of bytes which will be read.
waitForBytes - The minimum number of bytes to read before calling the callback function.
callback - Funtion which is executed when the read has been satisfied.
arg - Parameter to the callback function.
Returns:
Returns the associated callback handle.
Raises:
IOBaseException - A IOBaseException if internally: The handle or callback parameter was equal to GLOBUS_NULL, so the registration could not be processed or - The handle parameter was already registered for closing, so no more registrations can occur on this handle or - The handle parameter was already registered for reading or - The type of handle passed to the function by the handle parameter is not one of the types which supports the read operation.

register_write(self, data, dataLen, callback, arg)

Asynchronous TCP or file write.

Perform a write on the handle.
Parameters:
data - The data to be written.
dataLen - The size of the data buffer.
callback - Function which is executed when the write has completed.
arg - Parameter to the callback function.
Returns:
Returns the callback handle allocated for this callback.
Raises:
IOBaseException -

A IOBaseException if one of these internal events occurred:

The handle or callback parameter was equal to GLOBUS_NULL, so the registration could not be processed. The handle parameter was not initialized or ready, so the write registration could not be processed. The handle parameter was already registered for closing, so no more registrations can occur on this handle. The handle parameter was already registered for writing. The type of handle passed to the function by the handle parameter is not one of the types which supports the write operation. The handle cannot protect the data using the GSSAPI. The data cannot be written.

Warning: In the case of an error during a protected data transfer, the

try_read(self, buffer, maxBytes)

Nonblocking TCP or file read

globus_io_try_read() will read whatever data is immediatedly available from the handle without blocking. The value of nbytes_read will be updated to contain the amount of data actually read from this handle.
Parameters:
buffer - The buffer to read data into.
maxBytes - The maximum number of bytes which can be read.
Returns:
Returns the number of bytes read.
Raises:
IOBaseException - A IOBaseException if: The handle, buf, or nbytes_read parameter was equal to GLOBUS_NULL, so the operation could not be processed. The handle parameter was not initialized or ready, so the read operation could not be processed. The handle parameter was already registered for closing, so no more operations can occur on this handle. The handle parameter was already registered for reading. The buf parameter was not NULL, but was invalid. Some unexpectd I/O error occurred. An end-of-file occurred on the read.

Warning: this function will always return 0 bytes read for TCP

try_write(self, data, maxLen)

Nonblocking TCP or file write

try_write() will write whatever data can immediately processed by the operating system without blocking.
Parameters:
data - The data to write.
maxLen - The maximum number of bytes which can be written.
Returns:
Returns the number of bytes written.

Warning: This function will always return 0 bytes written for TCP

write(self, data, dataLen)

Blocking TCP or file write.

Perform a blocking write operation on the handle. This will block until the contents of data are written to the network or file, or an error occurs.
Parameters:
data - The data to write.
dataLen - The maximum number of bytes which can be written.
Returns:
Returns the number of bytes written.
Raises:
IOBaseException - A IOBaseException if one of these internal events occurred: The handle or nbytes_written parameter was equal to GLOBUS_NULL, so the write could not be processed. The handle parameter was not initialized or ready, so the write operation could not be processed. The handle parameter was already registered for closing, so no more operations can occur on this handle. The handle parameter was already registered for writing. The type of handle passed to the function by the handle parameter is not one of the types which supports the write operation. The handle cannot protect the data using the GSSAPI. The data cannot be written. The write called failed with an unexpected error. The errno returned by write() is accessible from the error object.

Warning: In the case of an error during a protected data transfer, the


Generated by Epydoc 2.1 on Tue Apr 4 14:32:56 2006 http://epydoc.sf.net