Skip to content

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