Skip to content

hololinked.core.zmq.rpc_server.QueuedScheduler

Bases: Scheduler

Scheduler class to schedule the operations of a thing in a queued loop.

Source code in hololinked\core\zmq\rpc_server.py
class QueuedScheduler(Scheduler):
    """
    Scheduler class to schedule the operations of a thing in a queued loop.
    """
    def __init__(self, instance: Thing, rpc_server: RPCServer) -> None:
        super().__init__(instance, rpc_server)
        self.queue = deque()
        self._one_shot = False
        self._operation_execution_ready_event = threading.Event()
        self._operation_execution_complete_event = threading.Event()

    @property
    def has_job(self) -> bool:
        return len(self.queue) > 0

    @property
    def next_job(self) -> Scheduler.JobInvokationType:
        return self.queue.popleft()

    def dispatch_job(self, job: Scheduler.JobInvokationType) -> None:
        """
        append a request message to the queue after ticking the invokation timeout clock

        Parameters
        ----------
        item: Tuple[RequestMessage, asyncio.Event, asyncio.Task, AsyncZMQServer]
            tuple of request message, event to indicate if request message can be executed, invokation timeout task 
            and originating server of the request
        """
        self.queue.append(job)
        self._job_queued_event.set()    

    def cleanup(self):
        self.queue.clear()
        return super().cleanup()

Functions

dispatch_job

dispatch_job(job: Scheduler.JobInvokationType) -> None

append a request message to the queue after ticking the invokation timeout clock

Parameters:

Name Type Description Default

item

tuple of request message, event to indicate if request message can be executed, invokation timeout task and originating server of the request

required
Source code in hololinked\core\zmq\rpc_server.py
def dispatch_job(self, job: Scheduler.JobInvokationType) -> None:
    """
    append a request message to the queue after ticking the invokation timeout clock

    Parameters
    ----------
    item: Tuple[RequestMessage, asyncio.Event, asyncio.Task, AsyncZMQServer]
        tuple of request message, event to indicate if request message can be executed, invokation timeout task 
        and originating server of the request
    """
    self.queue.append(job)
    self._job_queued_event.set()