Skip to main content

Python State-Machine library

Project description

Easy State-Machine for python

from easystate import * import time SPEED = 1

class Starting(State):
def eval(self):

print ‘Starting’ time.sleep(SPEED)

def on_start(self,e):

print “Hello”

def on_finish(self,e):

self.transition(“Listening”)

class Listening(State):

def eval(self):

print ‘Listening’ time.sleep(SPEED) self.raiseEvent(“connect”)

def on_start(self,e):

print “Preparing for listening”

def on_connect(self,e):

self.transition(‘Negotiation’)

class Negotiation(State):
def eval(self):

print ‘checking validity’ time.sleep(SPEED) print ‘authenticating’ time.sleep(SPEED) print ‘registering’ self.transition(“Connected”)

def on_start(self,e):

print ‘Negotiating’

class Connected(State):
def eval(self):

print ‘Connected’

def on_finish(self,e):

self.transition(“Listening”)

m = StateMachine(initialState=”Starting”) m.appendState(Starting()) m.appendState(Listening()) m.appendState(Negotiation()) m.appendState(Connected()) m.start()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easystate-0.3.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

easystate-0.3-py2.7.egg (5.1 kB view details)

Uploaded Source

File details

Details for the file easystate-0.3.tar.gz.

File metadata

  • Download URL: easystate-0.3.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for easystate-0.3.tar.gz
Algorithm Hash digest
SHA256 179bea5419370329d005c3983dca22c80d84581d85924f54265b5a05a22f6f7b
MD5 2b6047fc154bbd51c8f07d6828c80311
BLAKE2b-256 8f256ca78f73f596abcd857dfe6ad7d003b8c7f99cf11d01fad30f5a94aa3d65

See more details on using hashes here.

File details

Details for the file easystate-0.3-py2.7.egg.

File metadata

  • Download URL: easystate-0.3-py2.7.egg
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for easystate-0.3-py2.7.egg
Algorithm Hash digest
SHA256 984f18f712fe6937eeb13ab3cda115c1114a4f8dc4c7c9c10b75414a39344996
MD5 6de3f581c1de0c3022a0f1db16c4606c
BLAKE2b-256 dda4b9e48408d28ecc132e72ad82ccccd88ede362e3846d972b6ace14af5f4b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page