Monthly Archives: October 2011

JogaPY : PHP Example

Last night I posted about JogaPY and showed how to use it. Those examples were in python. Today I will show you how to use it using PHP . First you have to download . Now extract it.




include_once ‘jogapy/client.php’;

$jogapy = new jogapyclient(‘localhost’,3277);


$tasks = array();

$tasks[] = new Task(‘echo’,’Hey’);

$tasks[] = new Task(‘echo’,’Baby’);


foreach ($jogapy->result() as $task) {





Now save it as my_client.php .




include_once ‘jogapy/worker.php’;

$worker = new jogapyworker();
function say($arg) {
return $arg;


Now save it as my_worker.php and run it via php cli. Now run the worker to check the result.

JOGAPY : A Very Simple Job Distribution System

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:

from jogapy.server import *
server = JogapyServer(‘localhost’,3277)

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

Here is the code of a client.

from jogapy.client import *
client = JogapyClient((‘localhost’,3277))
for result in client.results():
print result.result

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

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

worker = JogapyWorker([('localhost',3277)])

Save the code as and execute it.

If you run the 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.