Super-basic implementation of a state machine using greenlets