-
Notifications
You must be signed in to change notification settings - Fork 971
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
How to stop a while loop in a scheduled job #203
Comments
If I'm able to understand the use case correctly. Then it's pretty simple. Since the You don't need another function to trigger the |
Thanks for your answer. The thing is that I would like that job to run until 6am let's say. |
Maybe I'm not approaching the problem properly though. I am making an alarm with light raising etc. I would like to run a program in the night for example, another one during the day and let's say blinking every hour. I have started using schedule because it seemed the easiest but is there a way to run the blinking program while the day program is running for example? Or is there a better solution than schedule for this? Thanks |
would like to know too. say, I've a job that needs to be run every 2 seconds but only for 10 times. How should we do that? |
@Chachapaslafrime and @jasonlcy91 So, this is how I'll approach the problem. Code snippet attached below: You need to import few dependencies to make sure this works.
Now, you write a wrapper function to control your application logic to suit the intended behavior i.e
The wrapper function decides when to trigger the alarm or in my case the effect variations. The
The idea behind this approach is that let the scheduler run always. But, only start or stop the alarm if it matches the certain conditions. Hope this approach helps... |
@Chachapaslafrime - Have you figured it out yet ? Else, let me know if you need any help. As this is not entirely an It seems |
I think I found a cleaner way
If you used |
The above implementation you've suggested solves the problem that you've posted. However, I would suggested few changes.
|
Hello,
I am using a while loop to vary the brightness of my unicorn pHat controled by a raspberry pi zero.
The job is scheduled (using the schedule module) to start at a certain time, but I don't know how to stop it. I have tried to schedule another job to off the LEDs but since schedule runs jobs in series, it never gets to the ending program.
Thanks for your help,
Charlotte
The text was updated successfully, but these errors were encountered: