Skip to content

Commit

Permalink
untested example gearman client and job inside a django app
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Jan 14, 2010
1 parent 596b0d6 commit fa9753d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Empty file added gearman_example/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions gearman_example/gearman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Example Gearman Job File.
Needs to be called gearman.py and reside inside a registered Django app.
"""

def reverse(input):
"""Reverse a string"""
return input[::-1]

Empty file.
Empty file.
18 changes: 18 additions & 0 deletions gearman_example/management/commands/gearman_example_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.core.management.base import NoArgsCommand
from django_gearman import GearmanClient, Task


class Command(NoArgsCommand):
help = "Execute an example command with the django_gearman interface"
__doc__ = help

def handle_noargs(self, **options):
sentence = "The quick brown fox jumps over the lazy dog."

print "Reversing example sentence: '%s'" % sentence
# call "reverse" job defined in gearman_example app (i.e., this app)
client = GearmanClient()
res = client.do_task(Task("gearman_example.reverse", sentence))

print "Result: '%s'" % res

0 comments on commit fa9753d

Please sign in to comment.