# eric7.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

None

### Class Attributes

BUFSIZE
CMD_BUFSIZE
MAX_TRIES

### Class Methods

None

### Methods

AsyncFile | Constructor
__checkMode | Private method to check the mode.
close | Public method to close the file.
fileno | Public method returning the file number.
flush | Public method to write all pending entries.
isatty | Public method to indicate whether a tty interface is supported.
pendingWrite | Public method that returns the number of strings waiting to be written.
read | Public method to read bytes from this file.
readCommand | Public method to read a length prefixed command string.
read_p | Public method to read bytes from this file.
readable | Public method to check, if the stream is readable.
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.
seekable | Public method to check, if the stream is seekable.
tell | Public method to get the filepointer position.
truncate | Public method to truncate the file.
writable | Public method to check, if a stream is writable.
write | Public method to write a string to the file.
write_p | Public method to write a json-rpc 2.0 coded 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 (socket)
  the socket object being wrapped
mode (str)
  mode of this file
name (str)
  name of this file

#### 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 OSError is raised.

mode (string)
  the mode to be checked

Raises OSError:
  raised to indicate a bad file descriptor

#### AsyncFile.close

close(closeit=False)

Public method to close the file.

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

#### AsyncFile.fileno

fileno()

Public method returning the file number.

Return:
  file number

Return Type:
  int

#### AsyncFile.flush

flush()

Public method to write all pending entries.

#### AsyncFile.isatty

isatty()

Public method to indicate whether a tty interface is supported.

Return:
  always false

Return Type:
  bool

#### AsyncFile.pendingWrite

pendingWrite()

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

Return:
  the number of strings to be written

Return Type:
  int

#### AsyncFile.read

read(size=-1)

Public method to read bytes from this file.

size (int)
  maximum number of bytes to be read

Return:
  the bytes read

Return Type:
  str

#### AsyncFile.readCommand

readCommand()

Public method to read a length prefixed command string.

Return:
  command string

Return Type:
  str

#### AsyncFile.read_p

read_p(size=-1)

Public method to read bytes from this file.

size (int)
  maximum number of bytes to be read

Return:
  the bytes read

Return Type:
  str

#### AsyncFile.readable

readable()

Public method to check, if the stream is readable.

Return:
  flag indicating a readable stream

Return Type:
  bool

#### AsyncFile.readline

readline(sizehint=-1)

Public method to read one line from this file.

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

Return:
  one line read

Return Type:
  str

#### 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 (int)
  maximum number of bytes to be read

Return:
  one line of text up to size bytes

Return Type:
  str

#### AsyncFile.readlines

readlines(sizehint=-1)

Public method to read all lines from this file.

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

Return:
  list of lines read

Return Type:
  list of str

#### AsyncFile.seek

seek(offset, whence=0)

Public method to move the filepointer.

offset (int)
  offset to move the filepointer to
whence (int)
  position the offset relates to

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

#### AsyncFile.seekable

seekable()

Public method to check, if the stream is seekable.

Return:
  flag indicating a seekable stream

Return Type:
  bool

#### AsyncFile.tell

tell()

Public method to get the filepointer position.

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

#### AsyncFile.truncate

truncate(size=-1)

Public method to truncate the file.

size (int)
  size to truncate to

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

#### AsyncFile.writable

writable()

Public method to check, if a stream is writable.

Return:
  flag indicating a writable stream

Return Type:
  bool

#### AsyncFile.write

write(s)

Public method to write a string to the file.

s (str, bytes or bytearray)
  text to be written

#### AsyncFile.write_p

write_p(s)

Public method to write a json-rpc 2.0 coded string to the file.

s (str)
  text to be written

#### AsyncFile.writelines

writelines(lines)

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

lines (list of str)
  list of texts to be written

Up

## AsyncPendingWrite

AsyncPendingWrite(file)

Module function to check for data to be written.

file (file)
  The file object to be checked

Return:
  Flag indicating if there is data waiting

Return Type:
  int

Up