title: State Machine in Python: Run Code in Transition or State?
body: <p>I am rather new to the python language, please bear with me on this one. </p>
  
  <p>I want to run two state machines in two separate threads, communicating to each other via a queue. I used the <a href="https://github.com/tyarkoni/transitions" rel="noreferrer">transitions</a> package to create the state machine.</p>
  
  <p>My understanding is that all actions/code that performs actions has to be tucked into the transactions. </p>
  
  <p>These lines are taken from the example of the transitions package, showing where to place the code for the transition</p>
  
  <pre><code># escapades. Because the legal department says so.
  self.machine.add_transition('complete_mission', 'saving the world', 'sweaty', 
                           after='update_journal')
  def update_journal(self):
          """ Dear Diary, today I saved Mr. Whiskers. Again. """
          self.kittens_rescued += 1
  </code></pre>
  
  <p>However, how would I watch my queue, once i reached a state, in order to react to messages sent there that would should cause a transition from one state to another? From my basic knowledge, I would expect code in my state to wait for a message that could trigger the transition and call the transition to the following state.</p>
  
  <p>I would have to create a thread inside the state machine, passing the state machine object as a argument in order to be able to trigger transitions. </p>
  
  <p>Am I understanding this package correctly? Or am I using it wrongly?</p>