class_docstr: Basic class is represented connection.
  
  It can be in state:
      WAIT_LEN --- connection is reading request len.
      WAIT_MESSAGE --- connection is reading request.
      WAIT_PROCESS --- connection has just read whole request and
                       waits for call ready routine.
      SEND_ANSWER --- connection is sending answer string (including length
                      of answer).
      CLOSED --- socket was closed and connection should be deleted.
docstr: Callback function for switching state and waking up main thread.
  
  This function is the only function witch can be called asynchronous.
  
  The ready can switch Connection to three states:
      WAIT_LEN if request was oneway.
      SEND_ANSWER if request was processed in normal way.
      CLOSED if request throws unexpected exception.
  
  The one wakes up main thread.
docstr_tok: ["Callback","function","for","switching","state","and","waking","up","main","thread",".","This","function","is","the","only","function","witch","can","be","called","asynchronous",".","The","ready","can","switch","Connection","to","three","states",":","WAIT_LEN","if","request","was","oneway",".","SEND_ANSWER","if","request","was","processed","in","normal","way",".","CLOSED","if","request","throws","unexpected","exception",".","The","one","wakes","up","main","thread","."]
code: def ready(self, all_ok, message):
      """Callback function for switching state and waking up main thread.
  
      This function is the only function witch can be called asynchronous.
  
      The ready can switch Connection to three states:
          WAIT_LEN if request was oneway.
          SEND_ANSWER if request was processed in normal way.
          CLOSED if request throws unexpected exception.
  
      The one wakes up main thread.
      """
      assert self.status == WAIT_PROCESS
      if not all_ok:
          self.close()
          self.wake_up()
          return
      self.len = 0
      if len(message) == 0:
          # it was a oneway request, do not write answer
          self._wbuf = b""
          self.status = WAIT_LEN
      else:
          self._wbuf = struct.pack("!i", len(message)) + message
          self.status = SEND_ANSWER
      self.wake_up()
  
imports: import logging
  import select
  import socket
  import struct
  import threading
  from collections import deque
  from six.moves import queue
  from thrift.transport import TTransport
  from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
label_desc: Use image node_id 4 for calling the Connection obj's underlying member method code with example usage: obj.ready(all_ok, message) without return types