forked from fwenzel/django-gearman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
untested example gearman client and job inside a django app
- Loading branch information
Fred Wenzel
committed
Jan 14, 2010
1 parent
596b0d6
commit fa9753d
Showing
5 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
gearman_example/management/commands/gearman_example_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|