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

How to abort polling ? #12

Open
oijkn opened this issue May 20, 2020 · 3 comments
Open

How to abort polling ? #12

oijkn opened this issue May 20, 2020 · 3 comments
Labels
question Further information is requested

Comments

@oijkn
Copy link

oijkn commented May 20, 2020

Hi,

Can you tell me how I can abort, exit, kill, cancel or any other method the poll ?

Because when I use Ctrl+c or stop my script, I wai a long time before I can regain control of the console.

Thank you for this good project and support.

@oijkn
Copy link
Author

oijkn commented May 21, 2020

Maybe one solution #13
It's working well on in my side.

@ddmee
Copy link
Owner

ddmee commented Sep 11, 2020

Hi @oijkn, sorry for the late reply. I don't think github was setup correctly to send my notifications.

Thanks for raising the issue. Yes, you are right, there's no built-in way to abort the polling. That is an interesting idea.

I suppose I had just not expected anyone would want to do that. As you can set a timeout or a max_tries value, so provided you know when you call poll(), then that would be normally the way to control when polling ends.

However, in this case, if you don't know how long you want to wait, or you want decide you want to stop the polling, then yes, there's no way to do it. And a signal could be the answer. Or at least, adding abort functionality could be useful.

@ddmee
Copy link
Owner

ddmee commented Sep 11, 2020

The thing is, when I'm in the python REPL, if I hit 'control-c' when polling is on-going, the keyboard immediately interupts the polling.

> python
Python 3.7.3 (v3.7.3)
Type "help", "copyright", "credits" or "license" for more information.
>>> def checker(x):
...   print('time is {0}'.format(x))
...   return False # always return false so polling never ends
...
>>> import polling2, time
>>> polling2.poll(time.time, check_success=checker, poll_forever=True, step=1)
time is 1599815583.927871
time is 1599815584.927925
time is 1599815585.9280493
time is 1599815586.9282694
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "polling2\polling2.py", line 215, in poll
    time.sleep(step)
KeyboardInterrupt
>>>

So I'm not sure I can replicate the issue you are having.

@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