def readFromFD(fd, callback):
 try:
  output = os.read(fd, 8192)
 except (OSError, IOError) as ioe:
  if (ioe.args[0] in (errno.EAGAIN, errno.EINTR)):
   return
  else:
   return CONNECTION_LOST
 if (not output):
  return CONNECTION_DONE
 callback(output)

def readFromFD ( fd , callback ) : try : output = os . read ( fd , 8192 ) except ( OSError , IOError ) as ioe : if ( ioe . args [ 0 ] in ( errno . EAGAIN , errno . EINTR ) ) : return else : return CONNECTION_LOST if ( not output ) : return CONNECTION_DONE callback ( output )
read from file descriptor .