Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
schedule module conundrum
#4
Somthing like this so the values are updated, cant test it, don't have schedule installed
import schedule

# import threading
import time
from datetime import datetime

# currenttime = datetime.now()
# hr = int(currenttime.strftime("%-H"))
# dt = currenttime.strftime("%c")
tempss = 1  # sensor status
tempsh = 1  # sensor history
currenttemp = 43  # random set value, actual value called from device file.


def job():
    currenttime = datetime.now()
    dt = currenttime.strftime("%c")
    message = """
    Alarm is still activated
    Current temperature is {}F
    {}""".format(
        currenttemp, dt
    )
    print(message)  # actual job script contains smtp protocals with execute send


while True:
    if tempss == 1 and tempsh == 1:
        schedule.every(1).minutes.do(job)
        schedule.run_pending()
    else:
        schedule.cancel_job()
Edit: looking at the module example the job schedule should be outside of the while loop
schedule.every(1).minutes.do(job)

while True:
    if tempss == 1 and tempsh == 1:
        schedule.run_pending()
    else:
        schedule.cancel_job()
    time.sleep(1)
Reply


Messages In This Thread
schedule module conundrum - by wgovideo - May-28-2019, 07:48 PM
RE: schedule module conundrum - by Gribouillis - May-28-2019, 08:42 PM
RE: schedule module conundrum - by wgovideo - May-28-2019, 09:31 PM
RE: schedule module conundrum - by Yoriz - May-28-2019, 09:45 PM
RE: schedule module conundrum - by wgovideo - May-28-2019, 09:54 PM
RE: schedule module conundrum - by Yoriz - May-28-2019, 09:57 PM
RE: schedule module conundrum - by wgovideo - May-28-2019, 10:05 PM
RE: schedule module conundrum - by Yoriz - May-28-2019, 10:09 PM
RE: schedule module conundrum - by wgovideo - May-28-2019, 10:29 PM
RE: schedule module conundrum - by wgovideo - May-29-2019, 03:38 AM
RE: schedule module conundrum - by Gribouillis - May-29-2019, 06:14 AM
RE: schedule module conundrum - by wgovideo - May-29-2019, 06:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Schedule exit a program at a specific time 4 am every day. chubbychub 3 404 May-17-2024, 03:45 PM
Last Post: chubbychub
  Cancelling previous schedule cosmarchy 2 2,968 Sep-15-2021, 04:55 PM
Last Post: Larz60+
  Hosting a script on a VPS, and on a schedule? oldguy 0 3,066 Mar-13-2021, 02:46 AM
Last Post: oldguy
  something i noticed about the "schedule" module Stan2292 1 1,862 Aug-30-2019, 06:04 AM
Last Post: buran
  How to schedule Jupyter Notebooks with Papermill wendysling 0 2,573 Jun-11-2019, 05:53 PM
Last Post: wendysling
  I got a problem with python schedule darktitan 2 3,629 Sep-22-2018, 12:49 PM
Last Post: darktitan
  Schedule with other processing RValentim 7 4,218 Jul-10-2018, 12:57 PM
Last Post: RValentim
  How to convert Schedule to APScheduler module? penguin9 2 3,910 May-03-2018, 12:44 PM
Last Post: penguin9
  Creating a schedule program ndplokkaar 4 4,107 Nov-23-2017, 04:21 PM
Last Post: ndplokkaar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020