Add support for terminating local workers

This commit is contained in:
Roberto Rosario
2012-08-03 17:38:38 -04:00
parent ac60654cc9
commit 384209d2aa
7 changed files with 66 additions and 18 deletions

View File

@@ -262,6 +262,15 @@ class Worker(models.Model):
def __unicode__(self):
return u'%s-%s' % (self.node.hostname, self.pid)
def terminate(self):
try:
process = psutil.Process(int(self.pid))
except psutil.error.NoSuchProcess:
# Process must have finished before reaching this point
return
else:
process.terminate()
class Meta:
ordering = ('creation_datetime',)
verbose_name = _(u'worker')