Skip to content

Commit

Permalink
Job now sends json data to the worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Singh committed Jan 9, 2012
1 parent d9f86ed commit b1334be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions job.py
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import gearman
import json

#
# Global variables
Expand Down Expand Up @@ -57,7 +58,7 @@ def __init__(self, job_id, timeout, retries, success_constraint,
def run(self):
global gearman_servers
worker_found = False
task_name = 'ls'
task_name = 'exe_cmd'

# Check if there are a workers that have the ssh job registered
# If not, bail out
Expand Down Expand Up @@ -88,7 +89,8 @@ def run(self):
for i in range(start, start + num_parallel):
try:
host = str(self._hosts[i]) # Gearman fails on unicode strings
gmjob = gmclient.submit_job(task_name, "hey " + str(host), background=False, wait_until_complete=False, max_retries=self._retries)
worker_args = json.dumps('{host:' + host + ', command:' + self._command +'}')
gmjob = gmclient.submit_job(task_name, worker_args, background=False, wait_until_complete=False, max_retries=self._retries)
self._gmjobs.append(gmjob)

except IndexError:
Expand Down

0 comments on commit b1334be

Please sign in to comment.