2011-05-22 23:02:03 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2011-05-24 12:21:49 +08:00
|
|
|
import gearman
|
|
|
|
|
|
|
|
def check_request_status(job_request):
|
|
|
|
if job_request.complete:
|
|
|
|
print "Job %s finished! Result: %s - %s" % (job_request.job.unique, job_request.state, job_request.result)
|
|
|
|
elif job_request.timed_out:
|
|
|
|
print "Job %s timed out!" % job_request.unique
|
|
|
|
elif job_request.state == JOB_UNKNOWN:
|
|
|
|
print "Job %s connection failed!" % job_request.unique
|
2011-05-22 23:02:03 +08:00
|
|
|
|
|
|
|
def main():
|
2011-05-24 12:21:49 +08:00
|
|
|
client = gearman.GearmanClient(['localhost:4730', 'otherhost:4730'])
|
|
|
|
completed_job_request = client.submit_job("ToUpper", "arbitrary binary data")
|
|
|
|
check_request_status(completed_job_request)
|
2011-05-22 23:02:03 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-05-24 12:21:49 +08:00
|
|
|
for i in range(100):
|
|
|
|
main()
|
2011-05-22 23:02:03 +08:00
|
|
|
|