Skip to main content

Random Sleep Timer in Python

·1 min

My company require an online attandence to be filled every morning. This should be submit every day at certain time and sometimes I forget to fill it. Desperate times require desperate measure. So I create automated task to fill it every morning. I’m using selenium to fill it and I need some random timer to fill it on different times each day. Below is the code I’m using to generate random sleep timer in python.

import random
import time

timeDelay = random.randrange(0, 3600)
time.sleep(timeDelay)

Sleep function is using seconds so it will generate a random interval within 1 hour.

Henry Thomas
Author
Henry Thomas
Just a guy with a pen and a dream