title: How to send data through TCPServer from another thread
body: <p>I'm writing a server in Python, which should basicaly work as a pipe between some serial device (like Arduino) and any client connected to it.</p>
  
  <pre><code>import SocketServer
  import threading
  import errno
  
  def SerialThread():
      # Serial init is here
      while (True):
          msg = read_from_serial(blocking = True)
          #print(msg)
          try:
              server.socket.sendall(str(msg))
          except IOError, e:
              if e.errno == errno.EPIPE:
                  print('Server not ready')
  
  serial_daemon = threading.Thread(name='SerialThread', target=SerialThread)
  serial_daemon.daemon = True
  serial_daemon.start()
  
  class TCPHandler(SocketServer.StreamRequestHandler):
      def handle(self):
          print('#')
  
  server = SocketServer.TCPServer(('127.0.0.1', 4242), TCPHandler)
  print('Starting server')
  server.serve_forever()
  </code></pre>
  
  <p>But I keep getting <code>Server not ready</code> spammed in my console. So what's wrong with my code, and how can I fix it?</p>