JOGAPY : A Very Simple Job Distribution System

By | October 19, 2011

A few days ago  I was learning the use of  Gearman . Then I thought why don’t I try to make a simple job distribution system like it using python. So I developed one and I call it JOGAPY .

Download it.

You can make a job server this way:

[python]
from jogapy.server import *
server = JogapyServer(‘localhost’,3277)
server.run()
[/python]

Now save it as myserver.py . It will start the job server if you execute it.

Here is the code of a client.

[python]
from jogapy.client import *
client = JogapyClient((‘localhost’,3277))
client.do_task([Task('echo','abcde'),Task('echo','fghij'),Task('echo','klmno'),Task('echo','pqrst')])
for result in client.results():
print result.result
[/python]

Save it as myclient.py . Now let’s make a worker.

[python]
from jogapy.worker import *
def echo(say):
return say

worker = JogapyWorker([('localhost',3277)])
worker.register_function(‘echo’,echo)
worker.work()
[/python]

Save the code as myworker.py and execute it.

If you run the myclient.py it will request the job server to process the echo function for it. If any free worker is connected with the server who can process the echo function the job server will tell him to do it. The worker will receive task info and it will start the process. When the task will be complete it will tell the server that the task is complete and it will send the task result to the server. Then the job server will send the task result to the client.

3 thoughts on “JOGAPY : A Very Simple Job Distribution System

  1. Pingback: JogaPY : PHP Example | My Blog

  2. Pingback: Jogapy : A Job Server Based On PHP | My Blog

  3. Pingback: 2011 | My Blog

Leave a Reply

Your email address will not be published. Required fields are marked *