Reputation: 12018
More out of curiosity, I was wondering how might I make a python script sleep for 1 second
without using the time
module?
Is there a computation that can be conducted in a while loop which takes a machine of n
processing power a designated and indexable amount of time?
Upvotes: 0
Views: 482
Reputation: 484
As mentioned in comments for your second part of question:
The processing time is depends on the machine(computer and its configuration) you are working with and active processes on it. There isnt fixed amount of time for an operation.
It's been a long time since you could get a reliable delay out of just trying to execute code that would take a certain time to complete. Computers don't work like that any more.
But to answer your first question: you can use system calls and open a os process to sleep 1 second like:
import subprocess
subprocess.run(["sleep", "1"])
Upvotes: 1