1

I am using Twisted and making a Looping Call every x seconds.

The function I use for the looping calls makes a return statement.

def f():
    # Obtain stuff
    return stuff

def main():
    LoopingCall(f).start(x)

How can I retrieve the return result of f?

Thanks!

RandomGuyqwert
  • 425
  • 6
  • 18

1 Answers1

0

Where do you want to "retrieve" the result of f from? LoopingCall is just called by the reactor, so this question doesn't really make sense. If you want main to somehow access the result that doesn't make sense, because main is run once, but f is run a potentially unlimited number of times.

So perhaps you just want to do this, instead:

def f():
    # Obtain stuff
    return stuff
def do_something_with_f():
    result = f()
    do_something(result)

def main():
    LoopingCall(do_something_with_f).start(x)
Glyph
  • 31,152
  • 11
  • 87
  • 129