# -*- coding: utf-8 -*-
"""
eww.stoppable_thread
~~~~~~~~~~~~~~~~~~~~
threading.Thread class that exposes a stop API. Subclasses of this
must check for .stop_requested regularly.
"""
import threading
[docs]class StoppableThread(threading.Thread):
"""Thread class that adds a stop() method. Subclasses *must* check for the
.stop_requested event regularly.
"""
[docs] def __init__(self):
"""Init."""
super(StoppableThread, self).__init__()
self.stop_requested = False
[docs] def stop(self):
"""Sets the stop_requested flag."""
self.stop_requested = True