mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-22 02:33:37 +00:00
32987134ba
Cleanup most init warnings. Cleanup some vars, pythonic instead of js. Some typos and python var/func names for Scheduler. Remove legacy handlers deprecated in 2020. Remove some legacy tagged stuff. Cleanup ConfigParser and 23.py Change cleanup vendored scandir. Remove redundant pkg_resources.py in favour of the vendor folder. Remove backports. Remove trakt checker. Change remove redundant WindowsSelectorEventLoopPolicy from webserveInit. Cleanup varnames and providers Various minor tidy ups to remove ide warnings.
50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
from lib.six import moves
|
|
|
|
import threading
|
|
|
|
|
|
class Event(object):
|
|
def __init__(self, etype):
|
|
self._type = etype
|
|
|
|
@property
|
|
def type(self):
|
|
return self._type
|
|
|
|
|
|
class Events(threading.Thread):
|
|
def __init__(self, callback):
|
|
super(Events, self).__init__()
|
|
self.queue = moves.queue.Queue()
|
|
self.daemon = True
|
|
self.callback = callback
|
|
self.name = 'EVENT-QUEUE'
|
|
self._stopper = threading.Event()
|
|
|
|
def put(self, etype):
|
|
self.queue.put(etype)
|
|
|
|
def stopit(self):
|
|
self._stopper.set()
|
|
|
|
def run(self):
|
|
while not self._stopper.is_set():
|
|
try:
|
|
# get event type
|
|
etype = self.queue.get(True, 1)
|
|
|
|
# perform callback if we got an event type
|
|
self.callback(etype)
|
|
|
|
# event completed
|
|
self.queue.task_done()
|
|
except moves.queue.Empty:
|
|
pass
|
|
|
|
# exiting thread
|
|
self._stopper.clear()
|
|
|
|
# System Events
|
|
class SystemEvent(Event):
|
|
RESTART = 'RESTART'
|
|
SHUTDOWN = 'SHUTDOWN'
|