0

I need to run a celery task retry inside the current task, and want to simplify this call (I have about 15 tasks like this).

How can I call the function inside itself, if I don't have the name and the kwargs?

def f(a=1, b=2, c=3):
    __this_function__(**kwargs)
BenMorel
  • 34,448
  • 50
  • 182
  • 322
xwild
  • 1,114
  • 2
  • 9
  • 25
  • 1
    I don't understand what you're asking, unless the answer you're looking for is "You can do `f(a, b, c)`". – BrenBarn Dec 27 '13 at 02:28
  • I need something like "self" for a function. – xwild Dec 27 '13 at 02:31
  • See http://stackoverflow.com/questions/452969/does-python-have-an-equivalent-to-java-class-forname. And you may store your function names in a array. – lin.mavs Dec 27 '13 at 02:32
  • If you have to put the code inside the function, there's no point in avoiding the function name or arguments. Why not put the retry code as a loop outside the function, or in a retry decorator? – user2357112 Dec 27 '13 at 02:36
  • @kwild: If that is so, I think you should edit your question to clarify. I'm not sure why you're even mentioning kwargs if all you want is a way for a function to refer to itself (which, incidentally, isn't possible in a simple way, see [this question](http://stackoverflow.com/questions/5063607/is-there-a-self-flag-can-reference-python-function-inside-itself)). – BrenBarn Dec 27 '13 at 02:36
  • I just need to add this section to many tasks and want to reduce possible errors in future.If I can call a retry without specifing the function/task name it simplify it. – xwild Dec 27 '13 at 02:44

0 Answers0