Simran Basi | af9b8e7 | 2012-10-12 15:02:36 -0700 | [diff] [blame] | 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 | |
| 5 | class _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): |
| 14 | """ |
| 15 | Add a new private variable _processes_to_kill to _AbstractDrone |
| 16 | """ |
| 17 | super(_SiteAbstractDrone, self).__init__() |
| 18 | self._processes_to_kill = [] |
| 19 | |
| 20 | |
| 21 | def queue_kill_process(self, process): |
| 22 | """Queue a process to kill/abort. |
| 23 | |
| 24 | @param process: Process to kill/abort. |
| 25 | """ |
| 26 | self._processes_to_kill.append(process) |
| 27 | |
| 28 | |
| 29 | def clear_processes_to_kill(self): |
| 30 | """Reset the list of processes to kill for this tick.""" |
| 31 | self._processes_to_kill = [] |
| 32 | |
| 33 | |
| 34 | def execute_queued_calls(self): |
| 35 | """Overloads execute_queued_calls(). |
| 36 | |
| 37 | If there are any processes queued to kill, kill them then process the |
| 38 | remaining queued up calls. |
| 39 | """ |
| 40 | if self._processes_to_kill: |
| 41 | self.queue_call('kill_processes', self._processes_to_kill) |
| 42 | self.clear_processes_to_kill() |
Prashanth B | 340fd1e | 2014-06-22 12:44:10 -0700 | [diff] [blame] | 43 | return super(_SiteAbstractDrone, self).execute_queued_calls() |