Working with thread events in Python
I recently wrote a multithreaded download queue manager in Python. I had the actual file downloads running in its own thread. I only wanted the program to download during certain times of day, and decided to implement this functionality using thread events. I set up my threaded class method for downloading to accept a “stop_event” parameter.
I then instantiated an event and passed it into the thread upon creation.
This allowed me to control the behavior of the thread and get it to not download files during certain times.