Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name Task #11

Open
klepfish opened this issue Sep 8, 2012 · 16 comments
Open

cannot import name Task #11

klepfish opened this issue Sep 8, 2012 · 16 comments

Comments

@klepfish
Copy link

klepfish commented Sep 8, 2012

When setting this up I get the error: cannot import name Task

@fwenzel
Copy link
Owner

fwenzel commented Sep 13, 2012

Thanks for the bug, that must have shown up in one of the recent changes @toudi added.

Can you provide the traceback you receive, so we know where the exception occurs?

@toudi
Copy link
Contributor

toudi commented Sep 13, 2012

i suppose it can be connected with the egg package You provide. The current source code needs python-gearman v. 2.x bindings, whether Your egg package has 1.5.x dependencies. I was going to notify You about this but have totally forgotten :/ I also have absolutely no idea about how the egg packages on github work so i don't know how to fix it :(

Please refer to the http://packages.python.org/gearman/1to2.html page for reference - Task class was present in gearman bindings v 1.x and was removed in 2.x.

best regards,
toudi.

@fwenzel
Copy link
Owner

fwenzel commented Sep 13, 2012

Oh, that's a different bug then.

I will have to revert commit d00dec3 for now, then, because that allowed gearman > 1.5.0.

If someone wants to fix the code so it is compatible with gearman 2.0, that's fine, I can accept that pull request then.

@fwenzel
Copy link
Owner

fwenzel commented Sep 13, 2012

Reverted in commit 3557977. Sorry for the trouble, @klepfish . This library works with gearman 1.5.0 only for now. But again, if someone fixes the code that relies on the old API, then I am happy to merge!

@fwenzel fwenzel closed this as completed Sep 13, 2012
@toudi
Copy link
Contributor

toudi commented Sep 13, 2012

ekhm, i believe it's quite opposite ;) The library now works with gearman api v. 2.x, not the 1.5.0. As i mentioned, the Task class was part of 1.x bindings :)

@fwenzel fwenzel reopened this Sep 13, 2012
@fwenzel
Copy link
Owner

fwenzel commented Sep 13, 2012

Okay I went too fast then. I can put the >= back in. It only supports 2.x now, right? So I'll change it to >= 2.0?

@toudi
Copy link
Contributor

toudi commented Sep 13, 2012

@klepfish, please try the following commands:

  1. pip uninstall gearman (this should uninstall gearman v. 1.x bindinds)
  2. pip install gearman (this should install upstream version - 2.x)

and see if the problem persists.

@fwenzel
Copy link
Owner

fwenzel commented Sep 13, 2012

Thanks, @toudi, I was confused. I increased the version info in setup.py in commit a8b05f0.

@ekid125
Copy link

ekid125 commented Oct 6, 2015

Hi everyone! Did this issue ever get resolved? I'm stuck here right now, can anybody suggest a solution?

Thank you very much!

@toudi
Copy link
Contributor

toudi commented Oct 6, 2015

@ekid125 can you do pip freeze | grep gearman on your virtualenv ? I just started from a fresh virtualenv, installed django-gearman package and it pulled gearman v.2 as a dependency.

the Task class was part of gearman v1 client API which is not supported anymore.

@ekid125
Copy link

ekid125 commented Oct 7, 2015

Hi Toudi!

The Gearman Version that I'm using is 2.0.2. So I guess it will not work. I did however change the call to:

client = GearmanClient()
res = client.submit_job("home.reverse", "reverse me!")
print "Result: '%s'" % res.result

That seemed to help a bit, however when I start "python manage.py gearman_worker" i do get the message that no gearman jobs are found!

I guess that's because of my "fix"?

Thank you!

@toudi
Copy link
Contributor

toudi commented Oct 7, 2015

well, the above code states that you have used the gearman client directly (without using django-gearman). Have you registered the jobs, as stated in the README ? (you have to create gearman_jobs.py inside your desired application)

cheers,
toudi

@ekid125
Copy link

ekid125 commented Oct 7, 2015

Hi @toudi! Yes I did create a File called gearman_jobs.py:

import os
import time

from django_gearman.decorators import gearman_job

@gearman_job
def reverse(input):
"""Reverse a string"""
time.sleep(1)
print "[%s] Reversing string: %s" % (os.getpid(), input)
return input[::-1]

As far as I understood decorating means registering the job as a worker, so gearman knows about it and uses that worker as soon as a job needs to be worked on.

So, I'm probably mixing django_gearman and gearman. So it's brobably best to just stick to one. Since django_gearman doesn't seem to be working with gearman 2.0 and above, I will probably have to stick with gearman.

Maybe you know an alternative?

Thank you!

@toudi
Copy link
Contributor

toudi commented Oct 7, 2015

no, those are two separate things. If you use 'just' gearman, then you won't have your django apps integrated.

I just started a plain fresh project, installed everythiing and it seems that you must use decorator calling in order to register the job, like so:

@gearman_job()

rather than

@gearman_job

As you progress with queues you will have to use the parenthesis anyways ;)

cheers,
toudi

@ekid125
Copy link

ekid125 commented Oct 7, 2015

Hey that worked :-) with "client.submit_job" instead of "client.do_task" it works like a charm!
No I have to test background jobs etc.

Thank you @toudi!

@ekid125
Copy link

ekid125 commented Oct 7, 2015

Hi @toudi I do have a question about background jobs which is not related to this topic, do you mind if I write you a pm or skype?

Thank you and best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants