Skip to content

Instantly share code, notes, and snippets.

@fabb
Last active December 14, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabb/5014867 to your computer and use it in GitHub Desktop.
Save fabb/5014867 to your computer and use it in GitHub Desktop.
Seemingly buggy behavior with PySCXML: the second event "f" is not received in most executions
import time
from scxml.pyscxml import StateMachine
import logging
logging.basicConfig(level=logging.NOTSET) # show detailed debug info
xml = '''
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="python" initial="S1">
<state id="S1">
<onentry>
<log expr="'hello S1'"/>
</onentry>
<transition event="s2" target="S2">
<log expr="'transition s2 from S1 to S2'" />
</transition>
<onexit>
<log expr="'bye S1'"/>
</onexit>
</state>
<state id="S2">
<onentry>
<log expr="'hello S2'"/>
</onentry>
<transition event="f" target="F">
<log expr="'transition f from S2 to F'" />
</transition>
<onexit>
<log expr="'bye S2'"/>
</onexit>
</state>
<final id="F">
<onentry>
<log expr="'hello F'"/>
</onentry>
</final>
</scxml>
'''
sm = StateMachine(xml)
sm.start_threaded()
sm.send("s2")
#time.sleep(1) #problem does not occur when sleeping in between
sm.send("f") #event is ignored in most executions, statemachine stays in state S2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment