issue: wait_for_condition cannot execute outside of the main task system

mhisted's Avatar

mhisted

22 Jan, 2020 03:12 PM

Hi Chris,

It looks like there's an issue where wait_for_condition() sometimes throws a 'cannot execute outside of the main state system' error. I've attached a testcase and a screenshot of the console error.

I'm not sure what's going on. Can you look into this?

thanks,
Mark

  1. 1 Posted by mhisted on 22 Jan, 2020 03:19 PM

    mhisted's Avatar

    Hi Chris,

    Small update. I was able to work around this particular issue with a while() { } block, manually spinning. So it's no longer super-urgent, but it would be nice to know what I did wrong here in the next few days.

    thanks,
    Mark

  2. Support Staff 2 Posted by Christopher Sta... on 22 Jan, 2020 04:10 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    You didn't do anything wrong. I was being a bit lazy when I implemented wait_for_condition and didn't want to support executing it inside a scheduled actions instance (which is the primary way an experiment can perform actions outside of the main state system). However, it didn't occur to me that this would also cause it to fail inside if and while (which are themselves implemented in a sort of lazy way that makes it appear to contained actions that they aren't running on the main state system). I will fix this.

    In the meantime, using a while loop is a good workaround, though I recommend including a short wait (e.g. 500us) in the loop body, so that you aren't burning up CPU cycles unnecessarily. If you need it in a bunch of places, you can create a macro for it.

    Cheers,
    Chris

  3. 3 Posted by mhisted on 23 Jan, 2020 01:09 AM

    mhisted's Avatar

    Hi Chris,

    Great, thanks for working on it.

    Re: the workaround, yes, that's exactly what I did --- added a holdoff each time through the loop. And I did set that time to 0.5ms as you suggested. We're on the same page.

    thanks!
    Mark

  4. Support Staff 4 Posted by Christopher Sta... on 27 Jan, 2020 05:27 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    This is fixed. As of the current nightly build, wait_for_condition can be used anywhere actions are allowed (including if, while, and scheduled actions).

    Cheers,
    Chris

  5. 5 Posted by mhisted on 27 Jan, 2020 05:33 PM

    mhisted's Avatar

    Thanks!

  6. Christopher Stawarz closed this discussion on 27 Jan, 2020 05:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac