1 |
slacapra |
1.1 |
import os, common, string
|
2 |
|
|
from Actor import *
|
3 |
|
|
from crab_util import *
|
4 |
|
|
|
5 |
|
|
class Killer(Actor):
|
6 |
|
|
def __init__(self, cfg_params, range):
|
7 |
|
|
self.cfg_params = cfg_params
|
8 |
|
|
self.range = range
|
9 |
|
|
return
|
10 |
|
|
|
11 |
|
|
def run(self):
|
12 |
|
|
"""
|
13 |
|
|
The main method of the class: kill a complete task
|
14 |
|
|
"""
|
15 |
|
|
common.logger.debug(5, "Killer::run() called")
|
16 |
spiga |
1.7 |
task = common._db.getTask(self.range)
|
17 |
slacapra |
1.1 |
toBeKilled = []
|
18 |
spiga |
1.7 |
for job in task.jobs:
|
19 |
|
|
# if id not in common._db.nJobs("list"):
|
20 |
|
|
# common.logger.message("Warning: job # "+str(id)+" doesn't exists! Not possible to kill it.")
|
21 |
|
|
# else:
|
22 |
|
|
if ( job.runningJob['status'] in ['SS','R','S']):
|
23 |
|
|
toBeKilled.append(job['jobId'])
|
24 |
|
|
else:
|
25 |
spiga |
1.8 |
common.logger.message("Not possible to kill Job #"+str(job['jobId'])+" : Status is "+str(job.runningJob['statusScheduler']))
|
26 |
spiga |
1.7 |
pass
|
27 |
slacapra |
1.1 |
|
28 |
spiga |
1.4 |
if len(toBeKilled)>0:
|
29 |
|
|
common.scheduler.cancel(toBeKilled)
|
30 |
|
|
common.logger.message("Jobs killed "+str(toBeKilled))
|