I call these text updates Feeds. A Feed object has some basic attributes like its content string, how many lives it has and its priority in the queue. I haven't made a unittest for this one, but below I have added a small test function for the purpose of posting this question. I use this to update statusbar in GUI applications.import threadingimport queueimport timeLOW_PRIORITY = 0MEDIUM_PRIORITY = 1HIGH_PRIORITY = 2class Feed(object):    def __init__(self, msg, life=1, priority=LOW_PRIORITY):        self.msg = msg        self.life = life        self.priority = LOW_PRIORITY if life == -1 else priority    def hit(self):        if self.life > 0:            self.life -= 1        elif not self.life:            raise ValueError(Feed {} is already dead..format(self))    def __bool__(self):        return True if self.life else False    def __lt__(self, obj):        if self.priority > obj.priority:            return True        return Falseclass FeedThread(threading.Thread):    def __init__(self, globevent, handler, updateinterval=3):        super(FeedThread, self).__init__()        self.globevent = globevent        self.handler = handler        self.updateinterval = updateinterval        self.feedqueue = queue.PriorityQueue()    def PushFeed(self, feed):        self.feedqueue.put(feed)    def run(self):        while not self.globevent.is_set():            try:                feed = self.feedqueue.get(block=True, timeout=1)                if feed:                    self.handler(feed.msg)                    feed.hit()                    self.PushFeed(feed)                    time.sleep(self.updateinterval)            except queue.Empty:                passdef test_feed():    newstime = threading.Event()    def bullettin(news):        print(\r{:^79}.format(news), end=)    scroll = FeedThread(newstime, bullettin)    scroll.start()    sports_feed = Feed(Barclays Premier League - Man Utd V Tottenham - 12:45,                        life=2, priority=MEDIUM_PRIORITY)    weather_feed = Feed(London - Cloudy, High 26C. Winds EDE at 15 to 30 km/h,                        life=-1)    entertainment_feed = Feed(Upcoming movie - Pixels (2015),                            life=2)    for feed in (sports_feed, weather_feed, entertainment_feed):        scroll.PushFeed(feed)    time.sleep(15)    breaking_feed = Feed(BREAKING NEWS - Cats love lasers - pew pew pew!,                         priority=HIGH_PRIORITY)    scroll.PushFeed(breaking_feed)    time.sleep(15)    newstime.set()if __name__ == __main__:    test_feed()
A tiny module for handling text updates
python;multithreading;python 3.x