Scheduler not working in python

Hey All -

I am trying to schedule a run for my repl and I just can’t get it to work. This is my first time posting and I would love your help.

Some background:

  • It’s pyton
  • works
  • the scheduler will run and output the time
  • I have asked the ghostwriter and have no idea
import os
import schedule
import time
from datetime import datetime
import pytz

# Define the time zone for your region
tz = pytz.timezone('America/New_York')

def run_main():
    current_time ='%Y-%m-%d %H:%M:%S')
    print(f"{current_time}  Running")

def tester():
    print('hello world')

def schedule_main():
  # Announce it has been called
  current_time ='%Y-%m-%d %H:%M:%S')
  print(f"Time zone is set to {tz}")
  print(f"called -- {current_time}")
  # Define the schedule for every weekday at 6am, 12pm, and 6pm EST

  print('Done with schedule')

  # Keep running scheduled jobs in the background
  while True:
      new_time ='%Y-%m-%d %H:%M:%S')

Hello @burkewise! Please edit your post’s code to be formatted like this:

Your code here

So that it is easier for staff and members of the community to help you with your issue!

Also see this guide on how to share your code:

PS: if you cannot edit your post, please read around a little to increase your trust level and let you access editing your posts.

Hmm, It looks like you aren’t running the functions called schedule_main(), run_main(), or tester(). Try putting at the bottom of your code

1 Like

Thank you so much for commenting. This is my first time posting for help and I am grateful for your engagement.

I call schedule_main() in, which I believe should call the rest. I have posted below.

import requests
from datetime import datetime

#Check the IP address to make sure google cloud allows it
response = requests.get('')
ip_address = response.text
print(f"The public IP address is: {ip_address}")

# import the functions. Need to be below the IP address so that it doesn't break first 
import jarvis_connections as cxn
import jarvis_functions as fxn
import scheduler as s

if __name__ == "__main__":
  calendard_ids = ['']
  response = requests.get('')
  ip_address = response.text
  print(f"The public IP address is: {ip_address}")
  service = cxn.authenticate_service()
  for calendar in calendard_ids:
      events = fxn.get_calendar_events(service, calendar)
      for i, event in enumerate(events):
        except Exception as e:
    except Exception as e:
  now =
  print(f"\nFinished processing events at {now.strftime('%Y-%m-%d %H:%M:%S')}")

# call schedule_main() here
print("Finished running")

so um do you have the schedule module created or not?

I do. The first message I posted is

1 Like

the first message… what? the module imports itself??

Maybe I’m not following so apologies in advance if this explanation isn’t relavant.

In, which is the code I posted in my first post, it imports schedule at the top. Then in, which is my second post, it imports scheduler as s in line 13 or so.