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

Add duration parameter to DataStream run method #493

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hnewey7
Copy link

@hnewey7 hnewey7 commented Aug 6, 2024

Added a duration parameter to the DataStream.run() method, allowing users to input a timedelta object to specify how long the DataStream should run for.

To implement this I've created a separate method called _run which takes the timedelta object and converts it into seconds. An aynscio task is then created using asyncio.create_task(self._run_forever()) and then this task is waited for using asyncio.wait(). The asyncio wait function has a timeout parameter in seconds which in this case is used to cancel the running of _run_forever when the duration is exceeded.

I've also added a unit test with a number of durations to test this feature.

@hnewey7 hnewey7 requested a review from hiohiohio as a code owner August 6, 2024 21:27
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