Linked Questions

1 vote
0 answers
1k views

Printing a message every minute in python [duplicate]

I am working to print out a message to the terminal once every minute. I cannot use time.sleep() because there are other things that need to continue to run. Here is the what I have so far, but I am ...
Veejay's user avatar
  • 535
108 votes
24 answers
101k views

Python Equivalent of setInterval()?

Does Python have a function similar to JavaScript's setInterval()? I would like to have: def set_interval(func, interval): ... That will call func every interval time units.
zjm1126's user avatar
  • 65.1k
41 votes
5 answers
36k views

Django - run a function every x seconds

I'm working on a Django app. I have an API endpoint, which if requested, must carry out a function that must be repeated a few times (until a certain condition is true). How I'm dealing with it right ...
Zeokav's user avatar
  • 1,683
10 votes
6 answers
13k views

Postponing functions in python

In JavaScript I am used to being able to call functions to be executed at a later time, like this function foo() { alert('bar'); } setTimeout(foo, 1000); This does not block the execution of ...
Andrea's user avatar
  • 20.4k
21 votes
4 answers
13k views

Equivalent of setInterval in python

I have recently posted a question about how to postpone execution of a function in Python (kind of equivalent to Javascript setTimeout) and it turns out to be a simple task using threading.Timer (well,...
Andrea's user avatar
  • 20.4k
12 votes
1 answer
12k views

Improve current implementation of a setInterval

I was trying to figure out how to make a setInterval that cancels in python without making an entire new class to do that, I figured out how but now I'm wondering if there is a better way to do it. ...
user3234209's user avatar
6 votes
1 answer
4k views

python threading.Timer start immediately not at specified time

i want to execute a function in every 3 second the code works if i call a function without arguments like below: def mytempfunc(): print "this is timer!" threading.Timer(5, mytempfunc).start()...
user1229351's user avatar
  • 2,005
6 votes
2 answers
9k views

Why no Timer class in Python's multiprocessing module?

So the threading module has a Timer class inhereted from Thread class to repeatedly execute some tasks. I was wondering why doesn't the multiprocessing module have something like an analogous ...
Manas's user avatar
  • 399
5 votes
2 answers
28k views

Running a background thread in python

All the examples I've been able to get to don't really address my problem, of having a certain procedure in the background constantly looping, while the rest of the program continues. Here is a ...
Constantly Confused's user avatar
4 votes
3 answers
5k views

python - printing something in a for loop every n seconds

I have a for loop that iterates over a number and performs some simple calculations. I am trying to figure out how to print out ( or log to file) the current value of 'val' every .5 to 1 second with ...
user982599's user avatar
3 votes
3 answers
3k views

Is it possible to execute function every x seconds in python, when it is performing pool.map?

I am running pool.map on big data array and i want to print report in console every minute. Is it possible? As i understand, python is synchronous language, it can't do this like nodejs. Perhaps it ...
avasin's user avatar
  • 9,436
3 votes
3 answers
10k views

Repeat function at an interval?

I'm making a wxPython app that I need to update a value from the internet every 15 seconds. Is there any way I can have a function to set the value, and make it run in the background at this interval, ...
tkbx's user avatar
  • 16k
2 votes
2 answers
3k views

How to schedule tasks without exiting existing loop?

I have struggled with this question for about a week -- time to ask someone who can bang out an answer in a couple minutes. I am trying to run a python program once every 10 seconds. There are a lot ...
Wapiti's user avatar
  • 1,891
0 votes
2 answers
3k views

Log value of variable every second in Python

I need to print the value of a variable every second or couple of seconds, while "at the same time" this variable is being modified. So I would be modifying this variable in my main function and I ...
Chrischpo's user avatar
  • 145
2 votes
2 answers
3k views

Python does something every 5 minutes

i need to check data on an API. The API is refreshed with new data every 5 minutes (10:00, 10:05, 10:10 etc...) I don't want to use time.sleep(300) because i want my script to do something at 10:05:03,...
Stitry's user avatar
  • 23

15 30 50 per page