'Python wait then break [closed]
I am trying to wait for user input. If no user input is provided then break. I found this code useful, but the problem is that it will continue if there was no user input provided. Is there something else I can add to make it break instead of continue?
The use case
I am sending a test email to myself. if the test email looks good I will send the email to the targeted people. I have two functions, one for the test and one for the real email. and between them, I need a break in case the test email has a problem.
import select
import sys
print('Press enter to continue.', end='', flush=True)
r, w, x = select.select([sys.stdin], [], [], 600)
print("the code will keep going after 600 seconds pass")
Solution 1:[1]
I would use input
input('Press enter to continue.')
Solution 2:[2]
based on python documentation I don't see an option to break after the time out [https://docs.python.org/3/library/select.html][1]
select.select(rlist, wlist, xlist[, timeout])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rowBee |
| Solution 2 | engzaz |
