• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5class _SiteAbstractDrone(object):
6    """
7    This is a site subclass of _BaseAbstractDrone in drones.py. Any methods
8    here automatically overload _BaseAbstractDrone and are used to create
9    _AbstractDrone for consumers.
10    """
11
12
13    def __init__(self, timestamp_remote_calls=True):
14        """
15        Add a new private variable _processes_to_kill to _AbstractDrone
16
17        @param timestamp_remote_calls: If true, drone_utility is invoked with
18            the --call_time option and the current time. Currently this is only
19            used for testing.
20        """
21        super(_SiteAbstractDrone, self).__init__(
22                timestamp_remote_calls=timestamp_remote_calls)
23        self._processes_to_kill = []
24
25
26    def queue_kill_process(self, process):
27        """Queue a process to kill/abort.
28
29        @param process: Process to kill/abort.
30        """
31        self._processes_to_kill.append(process)
32
33
34    def clear_processes_to_kill(self):
35        """Reset the list of processes to kill for this tick."""
36        self._processes_to_kill = []
37
38
39    def execute_queued_calls(self):
40        """Overloads execute_queued_calls().
41
42        If there are any processes queued to kill, kill them then process the
43        remaining queued up calls.
44        """
45        if self._processes_to_kill:
46            self.queue_call('kill_processes', self._processes_to_kill)
47        self.clear_processes_to_kill()
48        return super(_SiteAbstractDrone, self).execute_queued_calls()
49