Curses breaks a time.sleep() when terminal's size has been changed
<p>I  faced with behavior which I cannot understand.</p>

<pre><code>import curses
import time

myscreen = curses.initscr()

y, x = myscreen.getmaxyx()
i = 0

while y &gt;= 24 and x &gt;= 80 and i &lt;= 23:
    myscreen.addstr(i, 0, 'Python curses in action!')
    myscreen.refresh()
    y, x = myscreen.getmaxyx()
    i += 1
    time.sleep(1)

curses.endwin()
</code></pre>

<p>This code will write 24 strings with 1 second interval and it's ok.
But when I will begin to change size of terminal window during execution, strings will appear on screen much faster then 1 string per second.
Could you please explain this behavior and maybe get advice how to "protect" my time.sleep()?
Thanks.</p>

<p>P.S. without curses sleep() works fine.</p>

<p>From the documentation of <code>time.sleep()</code>:</p>

<blockquote>
  <p>Suspend execution of the current thread for the given number of
  seconds. The argument may be a floating point number to indicate a
  more precise sleep time. <strong>The actual suspension time may be less than
  that requested because any caught signal will terminate the sleep()
  following execution of that signalâs catching routine</strong>. Also, the
  suspension time may be longer than requested by an arbitrary amount
  because of the scheduling of other activity in the system.</p>
</blockquote>

python python-2.7 ncurses python-curses