Commits

Anonymous committed fe6fecb

[+] Doc strings

Comments (0)

Files changed (1)

 
 
 class IOLoopThread(Thread):
+
     def __init__(self):
+        """
+        Create instance
+
+        """
         Thread.__init__(self)
         self.running = True
         self.io_loop = ioloop.IOLoop.instance()
 
     def run(self):
+        """
+        Run IO Loop
+
+        """
         self.io_loop.start()
 
     def shutdown(self):
+        """
+        Stop IO Loop
+
+        """
         self.io_loop.stop()
 
 
 class RLampClient(object):
 
     def __init__(self, host="127.0.0.1", port=9999):
+        """
+        Creates instance
+        :param host: string
+        :param port: integer
+        """
         self.host = host
         self.port = port
         self.read_chunk_size = 16
         self.sock = None
 
     def start(self):
+        """
+        Start TCP client
+
+        """
         self._connect()
 
     def _connect(self):
+        """
+        Connect to server
+
+        """
         print "Connecting to server %s:%i" % (self.host, self.port)
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
         self.sock.connect((self.host, self.port, ))
         self.io_loop.update_handler(self.sock.fileno(), self.io_loop.READ)
 
     def _handle_events(self, fd, events):
+        """
+        Handle events
+
+        """
         if not self.sock:
             return
         if events and self.io_loop.READ:
             self._handle_error()
 
     def _handle_command(self):
+        """
+        Handle protocol command
+
+        :return:
+        """
         try:
             chunk = self.sock.recv(self.read_chunk_size)
         except socket.error, e:
         command_factory.run_command()
 
     def _handle_error(self):
+        """
+        Handle errors
+
+        """
         self._close_socket()
         print "Trying reconnect..."
         self._connect()
 
     def _close_socket(self):
+        """
+        Closing socket
+
+        :return:
+        """
         try:
             self.io_loop.remove_handler(self.sock.fileno())
         except: