Exemple #1
0
 async def handle_client_kill_job(self, client_addr,
                                  message: ClientKillJob):
     """ Handle an ClientKillJob message. Remove a job from the waiting list or send the kill message to the right agent. """
     # Check if the job is not in the queue
     if (client_addr, message.job_id) in self._waiting_jobs:
         del self._waiting_jobs[(client_addr, message.job_id)]
         # Do not forget to send a JobDone
         await ZMQUtils.send_with_addr(
             self._client_socket, client_addr,
             BackendJobDone(message.job_id,
                            ("killed", "You killed the job"), 0.0, {}, {},
                            {}, None, "", ""))
     # If the job is running, transmit the info to the agent
     elif (client_addr, message.job_id) in self._job_running:
         agent_addr = self._job_running[(client_addr, message.job_id)][0]
         await ZMQUtils.send_with_addr(
             self._agent_socket, agent_addr,
             BackendKillJob((client_addr, message.job_id)))
     else:
         self._logger.warning("Client %s attempted to kill unknown job %s",
                              str(client_addr), str(message.job_id))
Exemple #2
0
    async def handle_client_kill_job(self, client_addr,
                                     message: ClientKillJob):
        """ Handle an ClientKillJob message. Remove a job from the waiting list or send the kill message to the right agent. """
        # Check if the job is not in the queue
        if message.job_id in self._waiting_jobs:
            # Erase the job reference in priority queue
            job = self._waiting_jobs.pop(message.job_id)
            job._replace(msg=None)

            # Do not forget to send a JobDone
            await ZMQUtils.send_with_addr(
                self._client_socket, client_addr,
                BackendJobDone(message.job_id,
                               ("killed", "You killed the job"), 0.0, {}, {},
                               {}, "", None, "", ""))
        # If the job is running, transmit the info to the agent
        elif message.job_id in self._job_running:
            agent_addr = self._job_running[message.job_id].agent_addr
            await ZMQUtils.send_with_addr(self._agent_socket, agent_addr,
                                          BackendKillJob(message.job_id))
        else:
            self._logger.warning("Client %s attempted to kill unknown job %s",
                                 str(client_addr), str(message.job_id))