Python Forum
code keeps running if i use from threading import timer?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code keeps running if i use from threading import timer?
#2
To halt execution of the main thread while the timer is running, call the Timer.join() method. This forces the calling thread to wait for the Timer to complete.

As for the cancel operation, I'm thinking that you'll need a second thread. The second thread would call a function requesting input. If input is given, it cancels the countdelay() thread; if no input is given and the countdelay thread is completed, the thread terminates.
Reply


Messages In This Thread
RE: code keeps running if i use from threading import timer? - by stullis - Jan-25-2019, 04:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  writing and running code in vscode without saving it akbarza 5 2,236 Mar-03-2025, 08:14 PM
Last Post: Gribouillis
  Python: How to import data from txt, instead of running the data from the code? Melcu54 1 602 Dec-13-2024, 06:50 AM
Last Post: Gribouillis
  code timer Curbie 2 629 Aug-21-2024, 04:41 PM
Last Post: Curbie
  problem in running a code akbarza 7 2,246 Feb-14-2024, 02:57 PM
Last Post: snippsat
  the order of running code in a decorator function akbarza 2 1,291 Nov-10-2023, 08:09 AM
Last Post: akbarza
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 19,415 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Concurrent futures threading running at same speed as non-threading billykid999 13 4,518 May-03-2023, 08:22 AM
Last Post: billykid999
  Why is this import running twice? extan1 10 6,277 Feb-17-2023, 02:02 AM
Last Post: extan1
  using threading.Timer for function korenron 1 2,110 Dec-20-2022, 01:09 PM
Last Post: ndc85430
  Code running many times nad not just one? korenron 4 2,156 Jul-24-2022, 08:12 AM
Last Post: korenron

Forum Jump:

User Panel Messages

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