-
-
Notifications
You must be signed in to change notification settings - Fork 690
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
Adding delay function #1431
Adding delay function #1431
Conversation
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR; while this does implement functionality that will run on a delay, it's not exactly what #1415 was requesting.
The original request was to install a background task, and that task included a 5 second delay.
This PR implements an asynchronous method that does a sleep as it's first step.
The reason this matters is that you can only invoke your version of the method from an asynchronous context. This means it can't be invoked from a standard button handler, or from a generator.
@freakboy3742 I apologize for the delay in reverting. I understand there would be an issue with asynchronous context but I am not really sure on how to take this forward. One idea I have is to create a new thread which would add the method to background after the thread sleeps for the timeout duration. I am planning to use time.sleep in the new thread, this way there wouldn't be any asynchronous functions. Please let me know your views on this approach. |
There's no need to use threads - this can be done entirely with asyncio. However, you need to pay close attention to what it is that you're putting on the background task list. Your implementation here is "sleep for 2 seconds and then call a function". What we need is "call a function right now whose first action is to sleep for 2 seconds". |
Closing due to lack of activity. |
Add a function which facilitates to run a task after some time in background.
This PR fixes #1415
PR Checklist: