PyHadesContext
class
pyhades.PyHadesContext
(app)When you need run threads with PyHades with a web framework, where these frameworks have a main thread, the PyHades app must run with a context to avoid lock the main app with the main thread.
Usage
>>> from flask import Flask
>>> from pyhades import PyHades, PyHadesContext, State, PyHadesStateMachine
>>> flask_app = Flask(name)
>>> hades_app = PyHades()
>>> @hades_app.define_machine(name='TrafficLight', interval=1.0, mode="async")
class TrafficLightMachine(PyHadesStateMachine):
# states
...
>>> if name == "main":
>>> with PyHadesContext(hades_app):
flask_app.run()