Question

from celery.task import Task
class Decayer(Task):

    def calc_decay_value(self, x):
        y = (1.0/(2^x))
        return y

    def calc_decay_time(self, x):
        y  = 2^x
        return y

    def run(self, d, **kwargs):

        #do stuff.

        return 0


>>> decayer = tasks.Decayer(r)



Traceback (most recent call last):
  File "scanDecay.py", line 31, in <module>
    decayer = tasks.Decayer(r)
TypeError: object.__new__() takes no parameters
Was it helpful?

Solution

Two errors

1) Your class doesn't have an __init__ function. Either add one, or use this instead:

decayer = tasks.Decayer()

2) You are trying to raise an integer to the power of a float, but ^ means xor and cannot be used on floats. Use ** instead of ^:

y = 2 ** x

OTHER TIPS

The problem seems due to decayer = tasks.Decayer(r) call and tasks.Decayer is not designed to take a argument, because Task does not define a __init__ method which can take one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top