Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Timer Question
#1
Hi all -
I'm new to Python, so I apologize for this post - I'm not exactly sure what to be looking for, since when you search for "Python" and "Timer", there's an avalanche of information.

Essentially, what I'd like to do is run a timer in the background that executes a bit of code (let's say a print function) at a specified, recurring interval (let's say once every minute).

I'm using Python 3.7, if that changes the nature of the answer at all.

Thanks.
Reply
#2
In my opinion, that's kind of a broad question.
Are you going to be using a gui, shell, or some other way of executing the code?
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
What you describe is event scheduling,there is a build in sched.
What i have used before is schedule(easy to use) and APScheduler(more advance).
# pip install schedule
import schedule
import time

def p1():
    print("Hello")

def p2():
    print("World")

schedule.every(10).seconds.do(p1)
schedule.every(11).seconds.do(p2)

while True:
    schedule.run_pending()
    time.sleep(1)
Reply
#4
thank you! that works great.
i'm using shell.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Very Beginner question on simple variables Harvy 1 165 Apr-12-2024, 12:03 AM
Last Post: deanhystad
  Simple Question - ' defined as "a". ?' Ryan012 10 1,597 May-27-2023, 06:03 PM
Last Post: Ryan012
  Very simple question about filenames and backslashes! garynewport 4 1,925 Jan-17-2023, 05:02 AM
Last Post: deanhystad
  Python Tkinter Simple Multithreading Question AaronCatolico1 5 1,559 Dec-14-2022, 11:35 PM
Last Post: deanhystad
  A simple "If...Else" question from a beginner Serena2022 6 1,699 Jul-11-2022, 05:59 AM
Last Post: Serena2022
  Simple arithmetic question ebolisa 5 2,038 Dec-15-2021, 04:56 PM
Last Post: deanhystad
  Simple code question about lambda and tuples JasPyt 7 3,298 Oct-04-2021, 05:18 PM
Last Post: snippsat
Big Grin question about simple algorithm to my problem jamie_01 1 1,665 Oct-04-2021, 11:55 AM
Last Post: deanhystad
  email timer/rss feed timer ndiniz 1 2,077 Feb-02-2021, 07:18 PM
Last Post: nilamo
  Simple question 1234 4 2,258 Dec-04-2020, 12:29 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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