What are the ways to pass a variable say an array or JSON data from client to worker using gearman?
-
I have a gearman client in PHP which creates a task. The gearman worker in python grabs that task and tries to complete it. I want my client to pass an array or any other variable data to the worker. How do I do that?
-
Answer:
Found the solution myself. client - php : $client = new GearmanClient(); $client -> addServer(); $array = ('id' => 1, 'name' => 'abc); $task = $client->addTask('task', json_encode($array)); worker - python : def echoer(self, worker, job): data = json.loads(job.data) print job.data['id'], job.data('name') worker = Worker('localhost', '4730') # assume Worker is a class in which echoer is defined worker.registerTask('task', worker.echoer)# registerTask is defined in Worker class worker.work() # work is defined in Worker class
Hussain Tamboli at Quora Visit the source
Related Q & A:
- How to pass a variable from php to a modal?Best solution by Stack Overflow
- How to set value in the dropdown from a JSON data list?Best solution by Stack Overflow
- How to pass a variable from AlertDialog to an Activity?Best solution by Stack Overflow
- What are easy ways of writing a good essay?Best solution by Quora
- What are some ways be become a swiss resident?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.