Questions tagged [pytransitions]

Transitions is a lightweight, object-oriented state machine implementation in Python with many extensions.

Transitions is a flexible state machine library compatible with Python 2.7+ and Python 3+. It features extensions such as hierarchical/nested states, state diagrams, state decorators (e.g. Error states or Timeouts), thread-safe and asynchronous machines.

Resources

49 questions
1
vote
1 answer

get_triggers() in pytransitions not returning expected output

I am using the pytransitions library (documented here) to implement a Finite State Machine. One of the features outlined is the ability to get a list of the triggers for a specific state. Here is the example as per the documentation: transitions =…
Ramaq
  • 15
  • 4
1
vote
1 answer

Is raising exceptions safe within 'before' callback of a transitions.Machine model?

I am using the transitions FSM library. Imagine having an application FSM using the following code: from transitions import Machine import os class Application(object): states = ["idle", "data_loaded"] def __init__(self): self.data =…
Daniel
  • 311
  • 3
  • 12
0
votes
1 answer

Pytransitions: How can we accomplish a statemachine which posses the features of Hierarchical Machine and AsyncMachine in a single state machine?

I want to build a stat machine such that it can posses features of both HierarchicalMachine and AsyncMachine. I tried this code but Hierarchical and Async are not working simultaneously. ` from transitions.extensions.markup import MarkupMachine from…
0
votes
1 answer

pytransitions/transitions: Saving and restoring state in GraphMachine

I am using a GraphMachine to model a workflow of a MongoDB record. I am only storing the state in MongoDB and when I am reloading at a later time, I use the set_state() option on the machine to force it back to where it was left off. This all works…
St1
  • 21
  • 3
0
votes
0 answers

Using transitions state machine in Pydantic model

Originally asked here but I've narrowed down the problem further. Python's transitions library's Machine doesn't appear to work with Pydantic BaseModel classes. Even if I allow for arbitrarily adding attributes in the Config subclass, the code gets…
Dave Cook
  • 617
  • 1
  • 5
  • 17
0
votes
1 answer

How to cancel an asynchronous transition with PyTransition

I have a queued PyTransition state machine, with some state doing work in on_enter. However, I want the user to be able to stop the machine at any time without waiting. For that, I need a way to cancel transitions. Here is what I've found for now.…
Hugal31
  • 1,610
  • 1
  • 14
  • 27
0
votes
1 answer

pytransitions is there a simple way to get the history of triggered events

class Matter(object): def __init__(self, states, transitions): self.states = states self.transitions = transitions self.machine = Machine(model=self, states=self.states, transitions=transitions, initial='liquid') def…
Xuewen Li
  • 3
  • 1
0
votes
1 answer

How to implement retry logic?

I'm trying to use pytransitions to implement retransmit logic from an initialization state. The summary is that during the init state if the other party isn't responding after 1 second resend the packet. This is very similar to what I see here:…
0
votes
1 answer

AsyncGraphMachine used with async on_enter callbacks

My question is actually pretty simple, but I am not well versed in pytransition code to find the answer by myself: Is is possible to use AsyncGraphMachine with async on_enter callbacks only. In the documentation:…
Tobbey
  • 469
  • 1
  • 4
  • 18
0
votes
2 answers

Telegram bot with Finite State Machine

I am developing a telegram bot with FSM. It is should've chat-bot for ordering pizza. The conversation should be like this: What kind of pizza do you want? Big or small? Great How will you pay? In cash Do you want a big pizza, cash…
GermanGerken
  • 11
  • 1
  • 4
0
votes
1 answer

How to write correct transitions?

I have a bot code that needs to be connected to a state machine, how to implement it correctly, please help me, I understand in theory how to do this, but in practice, it does not work states.py from transitions import Machine, State from main…
0
votes
1 answer

How to use aiologger with pytransitions’ AsyncMachine?

I’m using AsyncMachine to model multiple objects interacting asynchronously and in principle, all works as expected, really a cool extension ;-) However, when I use logging, the millisecond delays which are reported in log entries between processing…
Eradian
  • 1
  • 2
0
votes
1 answer

How to display constantly updating text on fullscreen while going through states in a state machine?

I'm new to python and programming in general and I'm trying to build an algorithm using a state machine implementation by Pytransitions. I'm trying to find a way to display text on a small external LCD screen connected to an RPi 4 Model B while…
Suslik
  • 1
  • 1
0
votes
1 answer

GraphMachine doesn't generate graph for NarcolepticSuperhero quickstart example

I tried creating a Diagram using the NarcolepticSuperhero machine defined in the GitHub documentation but it only outputs this: Steps to recreate: Create a file named test.py, with this content: from transitions import Machine from…
kauedg
  • 827
  • 8
  • 20
0
votes
1 answer

What is the right way to use Nested states with pytransitions?

So i've been looking around on the pytransitions github and SO and it seems after 0.8 the way you could use macro-states (or super state with substates in it) has change. I would like to know if it's still possible to create such a machine with…