Coder Social home page Coder Social logo

cannot import name Task about django-gearman HOT 16 OPEN

fwenzel avatar fwenzel commented on May 17, 2024
cannot import name Task

from django-gearman.

Comments (16)

fwenzel avatar fwenzel commented on May 17, 2024

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?

from django-gearman.

toudi avatar toudi commented on May 17, 2024

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.

from django-gearman.

fwenzel avatar fwenzel commented on May 17, 2024

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.

from django-gearman.

fwenzel avatar fwenzel commented on May 17, 2024

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!

from django-gearman.

toudi avatar toudi commented on May 17, 2024

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 :)

from django-gearman.

fwenzel avatar fwenzel commented on May 17, 2024

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?

from django-gearman.

toudi avatar toudi commented on May 17, 2024

@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.

from django-gearman.

fwenzel avatar fwenzel commented on May 17, 2024

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

from django-gearman.

ekid125 avatar ekid125 commented on May 17, 2024

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

Thank you very much!

from django-gearman.

toudi avatar toudi commented on May 17, 2024

@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.

from django-gearman.

ekid125 avatar ekid125 commented on May 17, 2024

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!

from django-gearman.

toudi avatar toudi commented on May 17, 2024

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

from django-gearman.

ekid125 avatar ekid125 commented on May 17, 2024

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!

from django-gearman.

toudi avatar toudi commented on May 17, 2024

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

from django-gearman.

ekid125 avatar ekid125 commented on May 17, 2024

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!

from django-gearman.

ekid125 avatar ekid125 commented on May 17, 2024

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!

from django-gearman.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.