0

I am writing a Program in Python in which I have to trigger a block of Code after 3 minutes get passed, This could be done by getting minutes count i.e 3 or seconds count i.e 180 (in this case) can anybody tell me how to get this count. I have searched but discussions are all about elapsed time etc.

Salman Ahsan
  • 63
  • 2
  • 12
  • is your python code supposed to do something during those 3 minutes or just wait? – depperm May 11 '18 at 13:39
  • I am doing image processing, it will keep doing its work (i.e face detection and other work) during those 3 mins. – Salman Ahsan May 11 '18 at 13:41
  • @csmckelvey I am working on Raspberry Pi and I already have 2 threads running on it, I am with limited resources here. Would prefer to avoid thread here. – Salman Ahsan May 11 '18 at 13:45

1 Answers1

2

Good question. What about using elapsed time to measure time?

import time

a=time.time()
b=0
while(b<180):
    b=time.time()-a
    # add any other code you need to do 

just an idea...

daniel_hck
  • 1,100
  • 3
  • 19
  • 38
  • 1
    What is **b** here? did you attempt to run this before posting? I have tried to run this code and this is what I get _NameError: name 'b' is not defined_ – amresh tripathi Jan 30 '21 at 07:28
  • you are right. You can add b=0, just before the while loop ( I will edit the post) thanks – daniel_hck Jan 31 '21 at 15:07