question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple callbacks active at the same time

See original GitHub issue

Currently most of my state logic is contained in on_enter callbacks. Since in some states I have to periodical checks, these callbacks run until the sate finishes.

Now I just noticed that it is possible that the on_enter CB of the following state is activated, while the old callback hasn’t finished yet. Is this behaviour desired?

In my case I probably will have to start using mutexes … 😖

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bit-piratecommented, Aug 18, 2015

Have been pondering about my implementation a bit.

So, if I would move the trigger call out of the callback, then I would need to create separate worker methods. Those would do the actual work and when finished trigger the transition to the next state.

Now looking at implementing this, I cannot see another straight-forward approach apart from the “if state A do this, if state B do that”, which you have mentioned in your blog post:

if state == 'consent' and user_response == 'Agree':
    state = 'demographics'
elif state == 'demographics' and validate_demographics(data):
    save_demographics()
    state = 'personality'
...

But then again, I started using this package in order to avoid this approach.

Am I missing something here? Do you have more advanced sample code some where?

In my case there are several states with while loops in which another process is polled for information to decide on state transitions depending on the retrieved data.

0reactions
tyarkonicommented, Nov 12, 2015

Closing this and labeling wontfix for now. Still open to ideas though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Can two callbacks execute the code at the same time ...
node.js runs Javascript with a single thread. That means that two pieces of Javascript can never be running at the exact same moment....
Read more >
5 Rails Callbacks Best Practices Used at Gusto
Instead, try to make callbacks that are idempotent and can be safely run multiple times. This is especially important when you begin moving ......
Read more >
Multiple callback in one frame - Unity Forum
Hello guys, I'm starting a new project and I have some issue with the new Input System. I get multiple callbacks in one...
Read more >
Unify usage of multiple callbacks · Issue #896 · Lightning-AI ...
Allow having multiple loggers/callbacks for the same training loop. ... uniformly (ie. do the same action at the same time across all the ......
Read more >
Active Record Callbacks - Ruby on Rails Guides
With callbacks it is possible to write code that will run whenever an Active Record object is created, saved, updated, deleted, validated, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found