Why sleep Is Risky in Production Code
You might have heard that using blocking, waiting code, e.g., sleep in many languages, is discouraged. Why? Introduction to Sleep Sleep is a blocking, waiting function present in some languages. Here’s sleep in Ruby. # task.rb print "Starting task... " sleep 10 # Simulating some activity... puts "done." The user experiences a printed output, with ten seconds of time between the ellipses and “done.” $ ruby task.rb Starting task... done. It’s used when we want to wait for a task to be finished. Pretty cool, right? ...