title: Run a TCP and looped process in python
body: <p>I am trying to build an IoT device and looking forward to build something like this:</p>
  
  <p>Schematic:</p>
  
  <ol>
  <li>A python process which runs as a loop to interact with hardware components</li>
  <li>A TCP server(Pub-Sub) which takes commands from its clients and pass on to (1)</li>
  <li>(1) can interact with (2) to publish an event and (2) can interact with (1) to control the hardware</li>
  </ol>
  
  <p>Here is what I tried:</p>
  
  <ol>
  <li>Using twisted, I created a pub sub service</li>
  <li>tried to command that service to emit events</li>
  <li>TCP listener on a Node.js serever to interact with Twisted TCP server</li>
  </ol>
  
  <p>This is what I observed:</p>
  
  <p>Node.js server is able to send messages to Twisted server properly.</p>
  
  <p>Twisted blocks executing other code (Schematic:1) after calling <code>reactor.run()</code> as it starts listening on a port.</p>
  
  <p>I would like to have both the process run simultaneously and interact with each other.</p>
  
  <p>Is there a way to achieve this without using multithread or multiprocesses?</p>