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

polling with function return #14

Open
frantz2501 opened this issue May 26, 2020 · 1 comment
Open

polling with function return #14

frantz2501 opened this issue May 26, 2020 · 1 comment
Labels
question Further information is requested

Comments

@frantz2501
Copy link

I want to poll the return value of a function:

def myfunction():
   df=df_function()
   global value
   value=df[df['date']==date]
   return True

polling2.poll(
   lambda: myfunction == True,
   step=30,
   timeout=3600)
   print(value)

But does not work: the polling script runs indefinitely.

@ddmee
Copy link
Owner

ddmee commented Sep 11, 2020

Hi @frantz2501, sorry for the late reply. I didn't see this as I don't think github was setup to send me notifications correctly.

I assume you've already fixed your issue.

However, it looks like you are using the poll( method incorrectly. Your lambda function isn't going to work.

You have written, let me comment:

def myfunction():
   df=df_function()
   global value
   value=df[df['date']==date]
   return True  # Are you sure you always want the last line to return true?

polling2.poll(
   # There is no call to myfunction, you'd need to write 'myfunction() == True'
   # But you don't need to do this. You can just pass the name of your function as the first parameter (the parameter target)
   # and poll( will check it is true as the default
   lambda: myfunction == True,  
   step=30,
   timeout=3600)
   print(value)

So I would write:

def myfunction():
   df=df_function()
   global value
   value=df[df['date']==date]
   return True

polling2.poll(
   myfunction,
   step=30,
   timeout=3600)
   print(value)

@ddmee ddmee added the question Further information is requested label Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants