blob: ff43d9252329092611c94a8b137d475a98951a88 [file] [log] [blame]
Simran Basiaf9b8e72012-10-12 15:02:36 -07001# 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
Prashanth Bcf731e32014-08-10 18:03:57 -070013 def __init__(self, timestamp_remote_calls=True):
Simran Basiaf9b8e72012-10-12 15:02:36 -070014 """
15 Add a new private variable _processes_to_kill to _AbstractDrone
Prashanth Bcf731e32014-08-10 18:03:57 -070016
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.
Simran Basiaf9b8e72012-10-12 15:02:36 -070020 """
Prashanth Bcf731e32014-08-10 18:03:57 -070021 super(_SiteAbstractDrone, self).__init__(
22 timestamp_remote_calls=timestamp_remote_calls)
Simran Basiaf9b8e72012-10-12 15:02:36 -070023 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()
Prashanth B340fd1e2014-06-22 12:44:10 -070048 return super(_SiteAbstractDrone, self).execute_queued_calls()