# eric4.DebugClients.Python.AsyncFile

Module implementing an asynchronous file like socket interface for the debugger.

### Global Attributes

None

### Classes

AsyncFile | Class wrapping a socket object with a file interface.

### Functions

AsyncPendingWrite | Module function to check for data to be written.

## AsyncFile

Class wrapping a socket object with a file interface.

### Derived from

object

### Class Attributes

maxbuffersize
maxtries

### Class Methods

None

### Methods

AsyncFile | Constructor
__checkMode | Private method to check the mode.
__nWrite | Private method to write a specific number of pending bytes.
close | Public method to close the file.
fileno | Public method returning the file number.
flush | Public method to write all pending bytes.
isatty | Public method to indicate whether a tty interface is supported.
pendingWrite | Public method that returns the number of bytes waiting to be written.
read | Public method to read bytes from this file.
read_p | Public method to read bytes from this file.
readline | Public method to read one line from this file.
readline_p | Public method to read a line from this file.
readlines | Public method to read all lines from this file.
seek | Public method to move the filepointer.
tell | Public method to get the filepointer position.
truncate | Public method to truncate the file.
write | Public method to write a string to the file.
writelines | Public method to write a list of strings to the file.

### Static Methods

None

#### AsyncFile (Constructor)

AsyncFile(sock, mode, name)

Constructor

sock
  the socket object being wrapped
mode
  mode of this file (string)
name
  name of this file (string)

#### AsyncFile.__checkMode

__checkMode(mode)

Private method to check the mode.

This method checks, if an operation is permitted according to the mode of the file. If it is not, an IOError is raised.

mode
  the mode to be checked (string)

#### AsyncFile.__nWrite

__nWrite(n)

Private method to write a specific number of pending bytes.

n
  the number of bytes to be written (int)

#### AsyncFile.close

close(closeit=0)

Public method to close the file.

closeit
  flag to indicate a close ordered by the debugger code (boolean)

#### AsyncFile.fileno

fileno()

Public method returning the file number.

Returns:
  file number (int)

#### AsyncFile.flush

flush()

Public method to write all pending bytes.

#### AsyncFile.isatty

isatty()

Public method to indicate whether a tty interface is supported.

Returns:
  always false

#### AsyncFile.pendingWrite

pendingWrite()

Public method that returns the number of bytes waiting to be written.

Returns:
  the number of bytes to be written (int)

#### AsyncFile.read

read(size=-1)

Public method to read bytes from this file.

size
  maximum number of bytes to be read (int)

Returns:
  the bytes read (any)

#### AsyncFile.read_p

read_p(size=-1)

Public method to read bytes from this file.

size
  maximum number of bytes to be read (int)

Returns:
  the bytes read (any)

#### AsyncFile.readline

readline(sizehint=-1)

Public method to read one line from this file.

sizehint
  hint of the numbers of bytes to be read (int)

Returns:
  one line read (string)

#### AsyncFile.readline_p

readline_p(size=-1)

Public method to read a line from this file.

Note: This method will not block and may return only a part of a line if that is all that is available.

size
  maximum number of bytes to be read (int)

Returns:
  one line of text up to size bytes (string)

#### AsyncFile.readlines

readlines(sizehint=-1)

Public method to read all lines from this file.

sizehint
  hint of the numbers of bytes to be read (int)

Returns:
  list of lines read (list of strings)

#### AsyncFile.seek

seek(offset, whence=0)

Public method to move the filepointer.

Raises IOError:
  This method is not supported and always raises an IOError.

#### AsyncFile.tell

tell()

Public method to get the filepointer position.

Raises IOError:
  This method is not supported and always raises an IOError.

#### AsyncFile.truncate

truncate(size=-1)

Public method to truncate the file.

Raises IOError:
  This method is not supported and always raises an IOError.

#### AsyncFile.write

write(s)

Public method to write a string to the file.

s
  bytes to be written (string)

#### AsyncFile.writelines

writelines(list)

Public method to write a list of strings to the file.

list
  the list to be written (list of string)

Up

## AsyncPendingWrite

AsyncPendingWrite(file)

Module function to check for data to be written.

file
  The file object to be checked (file)

Returns:
  Flag indicating if there is data wating (int)

Up