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

python worker on ec2 instance not responding #5

@suraj-deshmukh

Description

@suraj-deshmukh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions