Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
schedule module conundrum
#1
I'm composing a simple temperature alarm notification system, and I'm stuck. I have everything working great with the exception of some scheduled functions ("reminder of active alarm" and "a weekly communication test". Currently I'm trying the "schedule module" but I'm having the same problems I did when I tried using "Timer=" and "threading" to accomplish this task. It appears that these function take a snapshot of the task and recycles it. I can't seem to get it to pull "current variables" like datetime and current temp before it executes the task. I'm pretty sure my problem is somewhere in *args & *kwargs but I can't figure it out. I've read the py.docs and googled the hell out of this, but I keep getting lost and I can't find an answer. None of the examples seem to illustrate this and I got no one to ask. I'm self-taught and I have to say I'm pretty impressed with how far I got. But, I'm stuuuck!! I've been banging my head on this little quirky problem for 4 days now. How does one pull current variables into a scheduled, timer or threaded function. Attached is a snip of my code where I think the problem is. If you run it, it illustrates the problem I'm referring to. datetime and currenttemp are getting recycled and are not getting updated prior to execution of the task/ I know I'm doing something fundamentally wrong, because I was getting similar results when I tried to use a timer and threading to accomplish this task.

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():
    print (message) #actual job script contains smtp protocals with execute send 
    
while True:
    if tempss ==1 and tempsh == 1:
        message= """
        Alarm is still activated
        Current temperature is {}F
        {}""".format (currenttemp, dt)
        schedule.every(1).minutes.do(job), dt 
        schedule.run_pending()
    else:
        schedule.cancel_job()
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 1,686 May-17-2024, 03:45 PM
Last Post: chubbychub
  Cancelling previous schedule cosmarchy 2 4,401 Sep-15-2021, 04:55 PM
Last Post: Larz60+
  Hosting a script on a VPS, and on a schedule? oldguy 0 3,617 Mar-13-2021, 02:46 AM
Last Post: oldguy
  something i noticed about the "schedule" module Stan2292 1 2,396 Aug-30-2019, 06:04 AM
Last Post: buran
  How to schedule Jupyter Notebooks with Papermill wendysling 0 3,005 Jun-11-2019, 05:53 PM
Last Post: wendysling
  I got a problem with python schedule darktitan 2 4,611 Sep-22-2018, 12:49 PM
Last Post: darktitan
  Schedule with other processing RValentim 7 5,395 Jul-10-2018, 12:57 PM
Last Post: RValentim
  How to convert Schedule to APScheduler module? penguin9 2 4,647 May-03-2018, 12:44 PM
Last Post: penguin9
  Creating a schedule program ndplokkaar 4 5,716 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