Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Python Threading.Timer Executes Immediately

Python Threading.Timer Executes Immediately

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
pythondesignhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    icemclean
    wrote on last edited by
    #1

    Hi there, I'm writing a small(ish) Python app that is designed to play a list of sounds. Ever seen QLab? A bit like that. The problem I have is this: I have a threading.Timer that (at the moment) prints to the console that a sound has finished playing - it will change the UI, eventually, but the printout is all I need for now - but the timer does not wait until the interval is complete before it fires the function. Code:

    playout_1_timer = threading.Timer(10.0,musicDone)
    playout_1_timer.start()

    def musicDone():
    print "Music finished playing"

    However, the timer does not wait the 10 seconds as it should, and calls musicDone as soon as .start() is called. What's going on? Thanks, icemclean

    E 1 Reply Last reply
    0
    • I icemclean

      Hi there, I'm writing a small(ish) Python app that is designed to play a list of sounds. Ever seen QLab? A bit like that. The problem I have is this: I have a threading.Timer that (at the moment) prints to the console that a sound has finished playing - it will change the UI, eventually, but the printout is all I need for now - but the timer does not wait until the interval is complete before it fires the function. Code:

      playout_1_timer = threading.Timer(10.0,musicDone)
      playout_1_timer.start()

      def musicDone():
      print "Music finished playing"

      However, the timer does not wait the 10 seconds as it should, and calls musicDone as soon as .start() is called. What's going on? Thanks, icemclean

      E Offline
      E Offline
      etkid84
      wrote on last edited by
      #2

      try this:

      import threading

      def musicDone():
      print("Music finished playing")
      playout_1_timer = threading.Timer(10.0, musicDone)
      playout_1_timer.start()

      David

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups