code: def validator(ch):
      
      global screen_needs_update
      try:
          if screen_needs_update:
              curses.doupdate()
              screen_needs_update = False
          return ch
      finally:
          winlock.release()
          sleep(0.01) # let receiveThread in if necessary
          winlock.acquire()
docs: Update screen if necessary and release the lock so receiveThread can run