I can not use django-gearman-commands make the worker work all the time

221 views Asked by At

I use django-gearman-commands to do some work like this document(http://pypi.python.org/pypi/django-gearman-commands/0.1) says.When I run the worker frist time ,it works well,but when I submit another job just like make a select query from DB,it can't work until I restart this worker,I found that the worker just can work well one time. When the worker can't work well ,it still can get value which I submit,but can't go on to do the work. I hope someone can help me . Here is my code:

@property
def task_name(self):
    return 'sync'

def do_job(self, id):
    post = Post.objects.get(pk = id)
    if post.photo is None and post.video is None:
        try:
            self.sync_text_to_facebook(post)
        except :
            print 'sync text error'
    else:
        try:
            self.sync_photo_to_facebook(post)
        except :
            print 'sync photo error'

When I frist submit a job,it works well,and then I submit another job ,it says can't find any post.

0

There are 0 answers