Package: python-gearman.libgearman
Version: 0.13.2-2+b1
Severity: wishlist
Tags: patch

Here is a set of sample Python programs I'd like to contribute to help
developers get started using these bindings.

I have also blogged about this here:

  http://feeding.cloud.geek.nz/2011/01/sample-python-application-using.html

Cheers,
Francois
commit aba7b35d4c694deb0e85d94af575d50c253dceb4
Author: Francois Marier <[email protected]>
Date:   Wed Jan 12 20:44:27 2011 +1300

    Add a python 2.6 sample

diff --git a/debian/python-gearman.libgearman.examples b/debian/python-gearman.libgearman.examples
new file mode 100644
index 0000000..14bbef0
--- /dev/null
+++ b/debian/python-gearman.libgearman.examples
@@ -0,0 +1,2 @@
+debian/simpleworker.py
+debian/simpleclient.py
diff --git a/debian/simpleclient.py b/debian/simpleclient.py
new file mode 100755
index 0000000..7f0b37a
--- /dev/null
+++ b/debian/simpleclient.py
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+from gearman import libgearman
+
+gm_client = libgearman.Client()
+gm_client.add_server('localhost')
+
+result = gm_client.do('print', 'test')
+#result = gm_client.do('print', 'fail')
+print result
diff --git a/debian/simpleworker.py b/debian/simpleworker.py
new file mode 100755
index 0000000..1add4fc
--- /dev/null
+++ b/debian/simpleworker.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+from gearman import libgearman
+
+def work(job):
+    workload = job.get_workload()
+    if workload == 'fail':
+        job.send_fail()
+    return workload
+
+gm_worker = libgearman.Worker()
+gm_worker.add_server('localhost')
+gm_worker.add_function('print', work)
+
+while True:
+    gm_worker.work()

Reply via email to