OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

What is the point of adding short sleep to while true loop?

  • Thread starter Thread starter jligeza
  • Start date Start date
J

jligeza

Guest
Across the internet, I've saw several examples of handling a service, which awaits for messages from clients in an endless loop, including a short sleep. Example:

Code:
while True:
    check_messages_stack()
    sleep(0.1)

What's the point of the sleep there? Is it supposed to save resources? If it does save some resources, would it be a meaningful amount?
<p>Across the internet, I've saw several examples of handling a service, which awaits for messages from clients in an endless loop, including a short sleep. Example:</p>

<pre><code>while True:
check_messages_stack()
sleep(0.1)
</code></pre>

<p>What's the point of the sleep there? Is it supposed to save resources? If it does save some resources, would it be a meaningful amount?</p>
 

Latest posts

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top