execlib/execlog/listener.py

35 lines
767 B
Python
Raw Normal View History

2024-04-20 01:43:52 +00:00
'''
Implements a file system watcher.
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):
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