from abc import ABC, abstractmethod from aiosched.task import Task class BaseDebugger(ABC): """ The base for all debugger objects """ @abstractmethod def on_start(self): """ This method is called when the event loop starts executing """ return NotImplemented @abstractmethod def on_exit(self): """ This method is called when the event loop exits entirely (all tasks completed) """ return NotImplemented @abstractmethod def on_task_schedule(self, task: Task, delay: float): """ This method is called when a new task is scheduled (not spawned) :param task: The Task object representing a aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task :param delay: The delay, in seconds, after which the task will start executing :type delay: float """ return NotImplemented @abstractmethod def on_task_spawn(self, task: Task): """ This method is called when a new task is spawned :param task: The Task object representing a aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def on_task_exit(self, task: Task): """ This method is called when a task exits :param task: The Task object representing an aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def before_task_step(self, task: Task): """ This method is called right before calling a task's run() method :param task: The Task object representing an aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def after_task_step(self, task: Task): """ This method is called right after calling a task's run() method :param task: The Task object representing an aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def before_sleep(self, task: Task, seconds: float): """ This method is called before a task goes to sleep :param task: The Task object representing an aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task :param seconds: The amount of seconds the task wants to sleep :type seconds: int """ return NotImplemented @abstractmethod def after_sleep(self, task: Task, seconds: float): """ This method is called after a tasks awakes from sleeping :param task: The Task object representing an aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task :param seconds: The amount of seconds the task actually slept :type seconds: float """ return NotImplemented @abstractmethod def before_io(self, timeout: float): """ This method is called right before the event loop checks for I/O events :param timeout: The max. amount of seconds that the loop will hang when using the select() system call :type timeout: float """ return NotImplemented @abstractmethod def after_io(self, timeout: float): """ This method is called right after the event loop has checked for I/O events :param timeout: The actual amount of seconds that the loop has hung when using the select() system call :type timeout: float """ return NotImplemented @abstractmethod def before_cancel(self, task: Task): """ This method is called right before a task gets cancelled :param task: The Task object representing a aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def after_cancel(self, task: Task) -> object: """ This method is called right after a task gets cancelled :param task: The Task object representing a aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task """ return NotImplemented @abstractmethod def on_exception_raised(self, task: Task, exc: BaseException): """ This method is called right after a task has raised an exception :param task: The Task object representing a aiosched Task and wrapping a coroutine :type task: :class: aiosched.task.Task :param exc: The exception that was raised :type exc: BaseException """ return NotImplemented