#!/usr/bin/env python2
from . import State
from threading import Thread

class StateMachine(object):
    def __init__(self):
        self.state = None
        self.states = dict()
        self.worker = None

        self.debug = 0

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.__name__, state))

        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()

    def signal(self, signal):
        if self.state:
            return self.state.signal(signal)

c7d99a353f0847108ab8332961f84512d7f4ec65
<mask token>


class StateMachine(object):
    <mask token>

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()
        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.
                __name__, state))
        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()
    <mask token>

<mask token>


class StateMachine(object):

    def __init__(self):
        self.state = None
        self.states = dict()
        self.worker = None
        self.debug = 0

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()
        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.
                __name__, state))
        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()
    <mask token>

<mask token>


class StateMachine(object):

    def __init__(self):
        self.state = None
        self.states = dict()
        self.worker = None
        self.debug = 0

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()
        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.
                __name__, state))
        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()

    def signal(self, signal):
        if self.state:
            return self.state.signal(signal)

from . import State
from threading import Thread


class StateMachine(object):

    def __init__(self):
        self.state = None
        self.states = dict()
        self.worker = None
        self.debug = 0

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()
        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.
                __name__, state))
        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()

    def signal(self, signal):
        if self.state:
            return self.state.signal(signal)

#!/usr/bin/env python2
from . import State
from threading import Thread

class StateMachine(object):
    def __init__(self):
        self.state = None
        self.states = dict()
        self.worker = None

        self.debug = 0

    def __del__(self):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

    def transition(self, state):
        if self.state:
            if self.worker:
                self.state.running = False
                self.worker.join()
                self.worker = None
            self.state.exit()

        if state in self.states:
            self.state = self.states[state]
        elif self.debug > 0:
            print('debug: {} has no state named "{state}"'.format(self.__name__, state))

        if self.state:
            self.state.entry()
            self.state.running = True
            self.worker = Thread(target=self.state.main)
            self.worker.start()

    def signal(self, signal):
        if self.state:
            return self.state.signal(signal)
