execlib/execlog/listener.py

43 lines
974 B
Python
Raw Normal View History

2024-04-20 01:43:52 +00:00
'''
See also:
- https://inotify-simple.readthedocs.io/en/latest/#gracefully-exit-a-blocking-read
2024-04-20 01:43:52 +00:00
'''
import threading
from execlog.event import Event
2024-04-20 01:43:52 +00:00
class Listener[E: Event](threading.Thread):
2024-04-29 00:21:33 +00:00
'''
Implements a file system watcher.
'''
def __init__(self, router: 'Router[E]'):
2024-04-20 01:43:52 +00:00
'''
Parameters:
router: associated Router instance that events should be passed to
2024-04-20 01:43:52 +00:00
'''
super().__init__()
self.router = router
def listen(self):
'''
Register a new listener endpoint
'''
2024-04-20 01:43:52 +00:00
raise NotImplementedError
def run(self):
'''
Begin listening for events. Typically a blocking loop that passes events to
attached Router.
'''
2024-04-20 01:43:52 +00:00
raise NotImplementedError
def stop(self):
'''
Begin listening for events. Typically a blocking loop that passes events to
attached Router.
'''
raise NotImplementedError