Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using interrupt while respecting the min_time #427

Closed
boazin opened this issue Jun 5, 2016 · 2 comments
Closed

using interrupt while respecting the min_time #427

boazin opened this issue Jun 5, 2016 · 2 comments

Comments

@boazin
Copy link

boazin commented Jun 5, 2016

I'm trying to acheive the following:
Run task1 every 30 seconds
Run task2 every 60 seconds and occasionally run task3 instead.

So I made 2 task sets one for task1, and the other for task2, task3 and a filler_task.
(with min_time of 15 seconds - the mean time of each set is 30 seconds)

The problem is I have to use interrupt for both task sets to run, the thing is it runs another one immediately, not after another 15 seconds (threw in min_time/max_time throughout the code - didn't help)

class Behavior1(TaskSet):
    min_wait = 15000
    max_wait = 15000

    @task(1)
    class Task1(TaskSet):
        min_wait = 15000
        max_wait = 15000

        @task(1)
        def do_task(self):
            # do stuff
            self.interrupt()

    @task(1)
    class TheRest(TaskSet):
        min_wait = 15000
        max_wait = 15000

        @task(5)
        def Task2(self):
            # do stuff
            self.interrupt()

        @task(5)
        def filler_do_nothing_task(self):
            self.interrupt()

        @task(1)
        def Task3(self):
               # do stuff
               self.interrupt()
@heyman
Copy link
Member

heyman commented Jun 14, 2016

Hi!

You could throw in a self.wait() before you call self.interrupt() (and time.sleep(15) would work just as well).

@heyman
Copy link
Member

heyman commented Jun 14, 2016

Closing this issue, but feel free to reply with any questions.

@heyman heyman closed this as completed Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants