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

Make sleep interruptible when request context expire. #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cedric-appdirect
Copy link

When using this library in a CLI tool, I like to connect a context to CTRL-C signal allowing for early interruption. The problem is that with very long second rate limit, you can get the CLI lock in a sleep that can not be interrupted which is not ideal. This PR address that problem by using the context from the request and a timer channel to handle this scenario.

This comes with test for verifying that SleepWithContext behave as expected. I have introduced the use of testify by habit mostly, but the test look nicer with it in my opinion. Let me know if you prefer a different approach for the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant