josiahmwalton / python3-gearman Goto Github PK
View Code? Open in Web Editor NEWPython 3 Gearman API - Client, worker, and admin client interfaces
License: Other
Python 3 Gearman API - Client, worker, and admin client interfaces
License: Other
Documentation link on README.md hasn't any target.
$ curl -i --location http://packages.python.org/python3-gearman/
HTTP/1.1 301 Moved Permanently
Content-length: 0
Location: https://packages.python.org/python3-gearman/
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 31 Aug 2020 07:24:53 GMT
Content-Type: text/html
Content-Length: 178
Location: https://pythonhosted.org/python3-gearman/
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
HTTP/2 404
content-type: application/octet-stream
server: nginx/1.13.9
accept-ranges: bytes
date: Mon, 31 Aug 2020 07:24:53 GMT
age: 5
x-served-by: cache-bwi5139-BWI, cache-hhn4060-HHN
x-cache: MISS, HIT
x-cache-hits: 0, 1
x-timer: S1598858694.677480,VS0,VE0
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-frame-options: deny
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-permitted-cross-domain-policies: none
content-length: 0
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.
Hello,
thanks for providing python3 gearman. I'm trying to use it and after doing "pip install python3-gearman" I still have this issue in my own code:
Test reinstall
$ pip install python3-gearman
Requirement already satisfied: python3-gearman in ./venv/lib/python3.6/site-packages (0.1.0)
Trying to use it in my own code:
import gearman
Which results in:
import gearman
ModuleNotFoundError: No module named 'gearman'
What I'm doing wrong?
We often used the following code to connect to gearman server to get job:
gm_worker = gearman.GearmanWorker(['localhost:4730'])
gm_worker.set_client_id('xxxworker')
gm_worker.register_task(b'xxx', func1)
gm_worker.work()
With python 2.7.18 and gearman package 'gearman(2.0.2)' installed, the code worked.
As python 2 is runing to the end of lifetime, we upgrade to python 3.6 and installing gearman python package 'gearman3(0.2.0)'. From then on, job sometimes missed, sometimes delayed no more than 10 seconds.
Now we have 2 worker,one for python 2.7.18 and gearman package 'gearman(2.0.2)', still working, but with limited python 2 time span; another for python 3.6 and gearman python package 'gearman3(0.2.0)', job sometimes missing and sometimes delayed.
Till now, we cannot find the cause.
Can somebody help?
Or are there any similar job server like gearman?
Many Thanks!
Howard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.