How would I program a script to proceed to a function, if an if statement takes far too long to complete?
I am currently in a situation, where a chunk of code (depending on the network) can take anywhere from half a second, to half an hour to complete, and I am researching a code patch which would cause the code to skip the if statement and proceed to a new code function if it takes over 10 seconds to complete.
I suspect that the answer may lie within threads, however I am unsure as its a programming concept with which I have no experience. I am open to any answers, no matter how elaborate.
An idiomatic solution is to use Timeout::timeout .
See https://stackoverflow.com/a/231662/393701 for an answer fitting your question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.