Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

python worker on ec2 instance not responding #5

Open
suraj-deshmukh opened this issue Oct 23, 2018 · 1 comment
Open

python worker on ec2 instance not responding #5

suraj-deshmukh opened this issue Oct 23, 2018 · 1 comment

Comments

@suraj-deshmukh
Copy link

suraj-deshmukh commented Oct 23, 2018

I have two aws ec2 instances. Client is running on first ec2 instance and worker is running on second ec2 instance. But worker on second ec2 instance is not responding to clients job and not even throwing any error.

client.py:

import python3_gearman as 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)

gm_client = gearman.GearmanClient(['34.253.103.1:4730'])  # 34.253.103.1 :- ip address of worker

completed_job_request = gm_client.submit_job("reverse", "Hello World!")
check_request_status(completed_job_request)

worker.py:

import python3_gearman as gearman
gm_worker = gearman.GearmanWorker(['46.51.130.13:4730'])  # 46.51.130.13 :- ip address of client

def task_listener_reverse(gearman_worker, gearman_job):
    print('Reversing string: ' + gearman_job.data)
    return gearman_job.data[::-1]

# gm_worker.set_client_id is optional
gm_worker.set_client_id('python-worker')
gm_worker.register_task('reverse', task_listener_reverse)

# Enter our work loop and call gm_worker.after_poll() after each time we timeout/see socket activity
gm_worker.work()

Ran gearmand using below command on both the instance:

sudo gearmand --listen=0.0.0.0 -d

Please suggest what's wrong on above method/code.

@odnanref
Copy link

in the listen try specifying the port

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants